Thursday, March 22, 2012
Python programming Day 03
#Define a procedure, product_list,
#takes as input a list of numbers,
#and returns a number that is
#the result of multiplying all
#those numbers together.
#product_list([9]) => 9
#product_list([1,2,3,4]) => 24
def product_list(my_list):
if len(my_list)==1:
return my_list[0]
else:
product=my_list[0]
for i in range(len(my_list)-1):
product=product*my_list[i+1]
return product
Subscribe to:
Post Comments (Atom)
Mounting USB drives in Windows Subsystem for Linux
Windows Subsystem for Linux can use (mount): SD card USB drives CD drives (CDFS) Network drives UNC paths Local storage / drives Drives form...
-
I. Five different ways to answer a question II. Use SOLO strategies to explain our thinking and reasoning III. SOLO Taxono...
-
Learning levels 1, 2, and 3 Learning levels 4, 5, and 6 References http://www.cccs.edu/Docs/Foundation/SUN/QUESTIONS%20FOR%20TH...
No comments:
Post a Comment