Answer to Question #272308 in Python for comscie

Question #272308

2. Write a python program that will be used for conversion. The Users


should have three choices for conversion:


1. Celsius to Fahrenheit


2. Meter to Feet


3. Seconds to Hours and Minutes


If the user selects 1, the program should ask the user to enter the value


in Celsius and convert to Fahrenheit.


If the user selects 2, the program should ask the user to enter the value


in meter and the program calculates the equivalent feet.


If the user selects 3, the program should ask the user to enter the


number of seconds and calculates the number of hours and minutes.


Example


450 seconds is equivalent to 0 hours, 7.5 minutes


4050 seconds is equivalent to 1 hours, 7.5 minutes

1
Expert's answer
2021-11-27T11:36:59-0500
option=int(input("Enter an option: "))
if option==1:
        celsius = float(input("Enter temperature in celsius: "))
        fahrenheit = (celsius * 9/5) + 32
        print('%.2f Celsius is: %0.2f Fahrenheit' %(celsius, fahrenheit))
elif option==2:
    def footToMeter(foot):
           return foot * .305


    print("Feet \t Meters")
    for foot in range(1,11):
        print(foot, "\t", footToMeter(foot))


elif option==3:
    def convert(sec):
        sec = sec % (24 * 3600)
        hour = sec // 3600
        sec %= 3600
        min = sec // 60
        sec %= 60
          
        return "%d:%02d:%02d" % (hour, min, sec)
    n = int(input("Enter the time in seconds: "))
    print(convert(n))

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