Use this function to write a program that prints a chart showing the Fahrenheit equivalents of all Cel- sius temperatures 0–100 degrees. Use one position of precision to the right of the decimal point for the results. Print the outputs in a neat tabular format that minimizes the number of lines of output while remaining readable.

Implement the following function fahrenheit to return the Fahrenheit equivalent of
a Celsius temperature.

F = 9/5C + 32


```
# Print charts showing Fahrenheit and Celsius temperatures.

# convert a Celsius temperature to Fahrenheit
def fahrenheit( celsiusTemperature ):
return ( 9.0 / 5 ) * celsiusTemperature + 32

# print table headers
print "Celsius Fahrenheit Celsius Fahrenheit"

# print Celsius to Fahrenheit from 0 to 100 degrees
# use four columns to minimize the number of lines of output
for cTemperature in range( 0, 50 ):
print "%7.0f %11.1f" % \
( cTemperature, fahrenheit( cTemperature ) ),
cTemperature += 50
print "%11.0f %11.1f" % \
( cTemperature, fahrenheit( cTemperature ) )

cTemperature += 1

print "%31.0f %11.1f" % \
( cTemperature, fahrenheit( cTemperature ) )
```

Celsius Fahrenheit Celsius Fahrenheit
0 32.0 50 122.0
1 33.8 51 123.8
2 35.6 52 125.6
3 37.4 53 127.4
4 39.2 54 129.2
5 41.0 55 131.0
6 42.8 56 132.8
7 44.6 57 134.6
8 46.4 58 136.4
9 48.2 59 138.2
10 50.0 60 140.0
11 51.8 61 141.8
12 53.6 62 143.6
13 55.4 63 145.4
14 57.2 64 147.2
15 59.0 65 149.0
16 60.8 66 150.8
17 62.6 67 152.6
18 64.4 68 154.4
19 66.2 69 156.2
20 68.0 70 158.0
21 69.8 71 159.8
22 71.6 72 161.6
23 73.4 73 163.4
24 75.2 74 165.2
25 77.0 75 167.0
26 78.8 76 168.8
27 80.6 77 170.6
28 82.4 78 172.4
29 84.2 79 174.2
30 86.0 80 176.0
31 87.8 81 177.8
32 89.6 82 179.6
33 91.4 83 181.4
34 93.2 84 183.2
35 95.0 85 185.0
36 96.8 86 186.8
37 98.6 87 188.6
38 100.4 88 190.4
39 102.2 89 192.2
40 104.0 90 194.0
41 105.8 91 195.8
42 107.6 92 197.6
43 109.4 93 199.4
44 111.2 94 201.2
45 113.0 95 203.0
46 114.8 96 204.8
47 116.6 97 206.6
48 118.4 98 208.4
49 120.2 99 210.2
100 212.0

Computer Science & Information Technology

You might also like to view...

Known networks fall within the boundaries of ____________________.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

The page is wider than it is tall in Portrait Orientation

Indicate whether the statement is true or false

Computer Science & Information Technology

How does watermark text usually display in a document?

A) As very light, washed-out text B) In the header or footer C) As bright bold text D) As text around the perimeter of the document

Computer Science & Information Technology

A real number (also called a(n) ____________________-point number) is a numerical value that includes a decimal portion.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology