IDLE.
Celsius = (Fahrenheit - 32) * 5/9
Fahrenheit = Celsius * 9/5 + 32
def get_int(prompt):
input to get a value
def fahrenheit_to_celsius_table(min, max):
for loop creating
Fahrenheit values between min and
max
def fahrenheit_to_celsius(fahr):
def celsius_to_fahrenheit_table(min, max):
for loop creating
Celsius values between min and
max
def celsius_to_fahrenheit(celsius):
min_fahrenheit = get_int("Minimum Fahrenheit: ")
max_fahrenheit = get_int("Maximum Fahrenheit: ")
print()
fahrenheit_to_celsius_table(min_fahrenheit, max_fahrenheit)
print()
min_celsius = get_int("Minimum Celsius: ")
max_celsius = get_int("Maximum Celsius: ")
print()
celsius_to_fahrenheit_table(min_celsius, max_celsius)
Minimum Fahrenheit: 30 Maximum Fahrenheit: 40 Fahrenheit Celsius ----------------------- 30 -1 31 -1 32 0 33 1 34 1 35 2 36 2 37 3 38 3 39 4 40 4 Minimum Celsius: 0 Maximum Celsius: 10 Celsius Fahrenheit ------------------ 0 32 1 34 2 36 3 37 4 39 5 41 6 43 7 45 8 46 9 48 10 50
pass. input
to give the variable number a value. input. pass statement from
fahrenheit_to_celsius_table. range to do this, and be careful
about the 2nd argument. pass statement from
fahrenheit_to_celsius. return statement in
fahrenheit_to_celsius. celsius = (fahr - 32) * 5/9Turn the value of celsius into an integer with an assignment statement using
round. str string conversion function on
both fahr and
celsius. fahr = celsius * 9/5 + 32
Minimum Fahrenheit: 30 Maximum Fahrenheit: 40 Fahrenheit Celsius ----------------------- 30 -1 31 -1 32 0 33 1 34 1 35 2 36 2 37 3 38 3 39 4 40 4 Minimum Celsius: 0 Maximum Celsius: 10 Celsius Fahrenheit ------------------ 0 32 1 34 2 36 3 37 4 39 5 41 6 43 7 45 8 46 9 48 10 50
cd it116/hw/hw7
python3 hw7.py
$ python3 hw7.py Minimum Fahrenheit: 30 Maximum Fahrenheit: 40 Fahrenheit Celsius ----------------------- 30 -1 31 -1 32 0 33 1 34 1 35 2 36 2 37 3 38 3 39 4 40 4 Minimum Celsius: 0 Maximum Celsius: 10 Celsius Fahrenheit ------------------ 0 32 1 34 2 36 3 37 4 39 5 41 6 43 7 45 8 46 9 48 10 50
Copyright © 2022 Glenn Hoffman. All rights reserved. May not be reproduced without permission.