Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

I am trying to create a program where a user can input the Fahrenheit temperature. I have to create a function that will convert the

I am trying to create a program where a user can input the Fahrenheit temperature. I have to create a function that will convert the Fahrenheit temperature into Celsius temperature. If the user doesn't enter a float number, the output should be: "Invalid input"

If the user enters "Exit", then the program should automatically output: "Bye".

The program is supposed to ask the user to enter a Fahrenheit temperature until the user enters "Exit" (basically a loop).

Here is what I have so far:

print('Fahrenheit to Celsius Converter.') print('Enter "Exit" to quit.') def fah_to_cel(value_fah): value_cel = 0.0 value_cel = (value_fah - 32) / (1.8) return value_cel value_c = 0.0 value_f = 0.0 value_f = input('enter temp') try: value_f = float(value_f) print(value_f, "in C is", value_cel) except ValueError: if value_f !="Exit": print("Invalid input") else: print('Bye')

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions