Due: October 14, 2024
Points: 100
In the given examples, what you type is in red and the program prints what is in black. Your program output should look exactly like the output in the examples, except that what you type won’t be in red. Also, the symbol “↵” is a newline (return or enter keys).
Hint: If you store the number to print in the variable v, use the following statement to print it:
print("You need to pay %.2f" % (v))To turn in: Please turn in the program in the file meal.py.
Cost of meal (0 to quit): 9.21↵ You need to pay 11.79 Cost of meal (0 to quit): 10↵ You need to pay 12.80 Cost of meal (0 to quit): 0↵
To turn in: Please turn in the program in the file grade.py.
Sample inputs and outputs:
Enter score: 160↵ Total possible: 200↵ A score of 160 out of 200 is a B Enter score: 72↵ Total possible: 200↵ A score of 72 out of 200 is an F Enter score: 90↵ Total possible: 121↵ A score of 90 out of 121 is a C Enter score: 75↵ Total possible: 50↵ The score 75 is greater than the total possible, 50
Compute the value of this sequence after 1,000,000 terms, and print the result after each 100,000 terms have been computed. Use the following print statement:
print("%7d\t%.15f" % (count, sum))where count is the number of iterations and sum is the value of the first count terms.
To turn in: Please turn in the program in the file pi.py.
Sample output: only the first 4 lines are shown
100000 3.141582653589720 200000 3.141587653589762 300000 3.141589320256464 400000 3.141590153589744
Find the bug(s) and fix it (them). Put in your comments what you changed.
Hint: The function to round a number x to two places is round(x, 2).
To turn in: Please turn in the program in the file ftok-fixed.py.
Sample output: from the correctly working program:
Enter temperature in degrees Fahrenheit> 100↵ 100.0 Fahrenheit is 310.93 Kelvin Enter temperature in degrees Fahrenheit> -459.67↵ -459.67 Fahrenheit is 0.0 Kelvin Enter temperature in degrees Fahrenheit> -600↵ That temperature is below 0 Kelvin, which is impossible
|
ECS 235A, Computer and Information Security Version of September 14, 2024 at 8:38PM
|
You can also obtain a PDF version of this. |