473,322 Members | 1,614 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

in-built functions

Is there any particular function to find the product of a list like you would have for sum[list of integers] to find sum
May 2 '10 #1

✓ answered by bvdet

Following are two ways using built-in function reduce().
Expand|Select|Wrap|Line Numbers
  1. >>> reduce(lambda x, y: x*y, [2,3,4,5], 1)
  2. 120
  3. >>> import operator
  4. >>> reduce(operator.mul, [2,3,4,5])
  5. 120

3 1465
Glenton
391 Expert 256MB
Err...yes. It's called the 'product' function, and you call it by typing 'product'. I know python's syntax can be hard to guess!
May 4 '10 #2
>>> import math
>>> d=[elem for elem in range(1,10)]
>>> d
[1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> product(d)
Traceback (most recent call last):
that's what I get
File "<stdin>", line 1, in <module>
NameError: name 'product' is not defined
May 4 '10 #3
bvdet
2,851 Expert Mod 2GB
Following are two ways using built-in function reduce().
Expand|Select|Wrap|Line Numbers
  1. >>> reduce(lambda x, y: x*y, [2,3,4,5], 1)
  2. 120
  3. >>> import operator
  4. >>> reduce(operator.mul, [2,3,4,5])
  5. 120
May 5 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: km | last post by:
Hi all, I which context is the inbuilt function buffer() used ? regards, KM
2
by: Raja | last post by:
IS there any inbuilt decimal to binary conversion function in C++
1
by: db2sysc | last post by:
All, We have listed out the INBUILT Function differences between Sybase and DB2. Kindly provide your feedback or corrections and for CHANGES - DO WE NEED TO CODE our own UDFs?
4
by: Russell | last post by:
I have an assignment that I have to complete. I have to write a windows app in C#. Here is the spec: 1/ Date Comparison Build a program that will find the number of days between two dates. You...
13
by: ragav | last post by:
How can i print anything without using printf( ) or anyother inbuilt function calls??
1
by: kaushikm | last post by:
How to access sql server inbuilt functions from java prepared statement ? I have used getdate() of sql in a java prepared statement and am connecting to sqlserver. But it's not working. What to do ?
2
by: wizard | last post by:
Hello Friends, There is a PHP function checkdate to check if a date is a valid Gregorian date. Is there any such function to check for a valid time like something in hh:mm:ss format? If not, can...
0
by: Anjana S | last post by:
hi.. i am creating a file transfer application to a remote location in vb.net...Are putfile and getfile inbuilt functions in vb.net just like connect(). if not how to implement uploading of files to...
2
by: kaushal | last post by:
i am trying to sort the strings without the functions ..but i can't bcz i can't trace out the javascript program...so need ur help..
1
by: gurtejgenius | last post by:
Hi, Is there and Inbuilt Functionality or API that I can use to Open any file with its assocaited Application in pocket PC or WIN Mobile (in C#.NET). For ex: 1. If there is Image file(JPG or...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.