In problem 1, the formula for converting centigrade to Kelvin had a typo. The “−” should have been a “+”.
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.
Write a program that prompts the user for a temperature in degrees Fahrenheit, and prints the corresponding centigrade and Kelvin temperatures. The temperature may be an integer or a real number. Round the temperatures to two places in the output.
Assume the input is valid; that is, the user will enter a real number.
To turn in: Please turn in the program in the file tempcvt.py.
Hint: The function to round a number x to two places is round(x, 2). So, to round x to two places, say round(x, 2).
Examples:
Enter temperature in degrees Fahrenheit: 3.14159 3.14 Fahrenheit is -16.03 centigrade and 257.12 Kelvin
Enter temperature in degrees Fahrenheit: -459.67 -459.67 Fahrenheit is -273.15 centigrade and -0.0 Kelvin
Enter temperature in degrees Fahrenheit: 212 212.0 Fahrenheit is 100.0 centigrade and 373.15 Kelvin
Prompt the user for the score and the total points possible. Reject any score that is greater than the total.
Assume the score and total are entered as integers.
To turn in: Please turn in the program in the file grade.py.
Hint: Use the function to round x to the nearest integer like this: round(x).
Examples:
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
To turn in: Please turn in the program in the file cd.py.
Examples:
Number of days: 150 After 150 days, the number of deaths predicted is 95029
Number of days: 30 After 30 days, the number of deaths predicted is 1152
Number of days: 8 The number of days, which was input as 8 must be at least 18
To turn in: Please turn in the program in the file tempcvt-ex.py.
Examples:
Enter temperature in degrees Fahrenheit: hello The input must be a real number
Enter temperature in degrees Fahrenheit: 100..5 The input must be a real number
|
ECS 235A, Computer and Information Security Version of September 27, 2021 at 2:05PM
|
You can also obtain a PDF version of this. |