Python 1: Introduction to Python
Homework 4
Due
Sunday
Deliverables
There is one deliverable for this assignment
Specification
Write a program that prints a table of Celsius temperatures from 0 to 20 degrees and
prints the corresponding temperature in Fahrenheit.
This program MUST use a loop.
You MUST use the Python round
function on the Fahrenheit
value so only integer values appear in the tables.
Each column must have a label at the top specifying Celsius and Fahrenheit
and their must be a line between these column labels and the data that
follows.
The first digit in each temperature must line up with the labels
for each temperature so the output forms neat columns.
Suggestions
- Write a loop that runs from 0 to 20 and have it print out those values.
These are the Celsius values.
Run the script and fix any errors.
- Add a formula to the loop which converts a Celsius temperature into a Fahrenheit temperature.
Make sure the result is an integer.
Change the print statement so it prints both temperatures.
Run the script and fix any errors.
- Add a tab or use the
format
function to the print statement
so both temperatures will be aligned in vertical columns.
Run the script and fix any errors.
- Add a print statements before the loop that prints the name of the temperatures
and a line of dashes, -.
Run the script and fix any errors.
Testing
Your output should look like this.
Celsius Fahrenheit
------------------
0 32
1 34
2 36
3 37
4 39
5 41
6 43
7 45
8 46
9 48
10 50
11 52
12 54
13 55
14 57
15 59
16 61
17 63
18 64
19 66
20 68