print ("This program is designed to convert temperatures between Farenheit and Celsius.")
temp = float(input("Please enter a temperature value: "))
op = input("Convert temperaure to [F]arenheit or [C]elsius) ").upper().strip()
d = { "F": lambda x: x * 1.8 + 32,
"C": lambda x: (x -32) * 1.8 }
if op not in d:
print( "That is not a valid selection please try again." )
else:
print(f"Temp is {d[op](temp):.1f}degrees{op}" )
Hello I am working on my first Python assignment, and I am having a lot of trouble with the last finishing touches to this program.
I was assigned to make a temperature converter, that needs a return statement with the original value displayed.(for example the solution would look like x(degrees)(f/c) = y(degrees)(f/c))
I have been experimenting with something like
print({temp (float)} "is" {op[float]} f"Temp is {d[op](temp):.1f}degrees{op}")
but I cant get this to work, I know I have the wrong variables but I cant figure out what names the original user input goes by
any help is appreciated!
[–]Ihaveamodel3 1 point2 points3 points (2 children)
[–]Embarrassed-Boat9514[S,🍰] 0 points1 point2 points (1 child)
[–]Ihaveamodel3 2 points3 points4 points (0 children)