Answer to Question #314159 in Python for junior

Question #314159

 A) Create a function called To_Celsius that takes in a temperature in Fahrenheit temperature and returns the equivalent in Celsius.

B) Create another function called To_Fahrenheit that takes in a temperature in Celsius and returns the equivalent in Fahrenheit.

C) Use these functions to write a function called Print_EQ_Temps that prints out the Fahrenheit equivalents of all Celsius temperatures from 0°-100°, and the Celsius equivalents of all Fahrenheit temperatures from 32°-212°. Then, call this function in your program.


Hint: Use for loops to input into your functions.


1
Expert's answer
2022-03-21T12:36:30-0400
def to_celsius(fahrenheit):
    return 5 * (fahrenheit - 32) / 9
    
def to_fahrenheit(celsius):
    return 9 * celsius / 5 + 32

def print_eq_temps():
    for i in range(1, 101):
        print(str(i) + "C\u00b0 = "
                + str(to_fahrenheit(i)) + "F\u00b0")
    print("\n")
    for i in range(32, 213):
        print(str(i) + "F\u00b0 = "
                + str(round(to_celsius(i), 1)) + "C\u00b0")

print_eq_temps()

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS