Introduction to Scientic Programming
Spring 2013
Rowan University
Lab 7: Practicing while loops
This lab is exercise 7.5 from the textbook.
The brilliant mathematician Srinivasa Ramanujan found an innite series that can be used to generate a numerical
app
Introduction to Scientic Programming
Spring 2013
Rowan University
Lab 8: Practicing for loops
1. The factorial function, usually written n! in math class, is a function that returns the product of all the numbers
from 1 to n; that is, the product 1 * 2 *
Introduction to Scientic Programming
Spring 2013
Rowan University
Lab 9: Strings
Write a function past_tense(verb) which returns the past tense form of the specied English verb. Use these rules to
write your function.
Rule
Example: Present tense Past tens
Introduction to Scientic Programming
Spring 2013
Rowan University
Lab 11: Practicing loops
1. Write a fruitful function sum_of_factorials(N) that returns the sum of the rst N values of this series:
1
1 .
1
1
+
+
+
+
( N 1)!
0! 1! 2!
1
1
1111
For example,
Introduction to Scientic Programming
Spring 2013
Rowan University
Lab 12: Practicing loops, lists, and strings
1. Write a fruitful function power_list(N) that returns a list containing the rst N powers of 2.
For example, if N is 3, the function should ret
Introduction to Scientic Programming
Spring 2013
Rowan University
Lab 13: Practicing nested lists
In all of these lab problems, you may report the answers either as integers or as oats. If your program does integer division, you will get integer answers;
aR = 10.00
bR = 15.00
cR = 20.00
while True:
try:
count = 1
a = eval(input("Enter the amount of A seats sold: ")
b = eval(input("Enter the amount of B seats sold: ")
c = eval(input("Enter the amount of C seats sold: ")
total = (a
aTot = a *
bTot = b *
cTo