Saturday, 19 February 2022

It Executes 5 times before quitting to convert Celsius temps into Fahrenhit

 Modify the convert.py program (Section 2.2) with a loop so that it executes 5 times before quitting. Each time through the loop, the program  should get another temperature from the user and print the converted value.


CODE :

#convert.py
#Python program :It Executes 5 times before quitting to convert Celsius temps into Fahrenhit

def main():
    print("This program convert Celsius temps into Fahrenhit")
    for i in range(5):
        celsius=eval(input("What is the Celsius temprarure outside now ?"))
        fahrenhit = 9/5 * celsius + 32
        print("Aha , I know temprature is ", fahrenhit , "degrees fahrenhit.")

main()

NOTE : save above file as convert_v1.py

SCREENSHOT :



No comments:

Post a Comment