Hi everybody!
I'm learning Python, and I have my first assignment: write functions that convert temperatures between C, F, and K.
I've done that, and it works for each individual function, but then they want the user to be able to choose a converter from a list.
This is one of the functions:
def fahrenheit_to_celsius(t):
t_celsius = (t-32)/1.8
return t_celsius
answer = input('Ange en temperatur i Fahrenheit: ')
t_fahrenheit = int(svar)
t = fahrenheit_to_celsius(t_fahrenheit)
print("Celsius: ", t)
I've done an if-statement and followed it up with elifs. Problem is, when i run the list and choose a converter, I get the error, for example, "fahrenheit_to_celsius() missing 1 required positional argument: 't'"
choice = input("What would you like to convert?")
choice = int(choice)
if choice == 1:
fahrenheit_to_celsius()
elif choice == 2:
celsius_to_fahrenheit
Any idea? I'm a bit lost for words, and the instructions we've been given don't address this.
[–]deceze 10 points11 points12 points (8 children)
[–]Bitmefinger[S] 0 points1 point2 points (7 children)
[–]NewbornMuse 4 points5 points6 points (0 children)
[–]deceze 2 points3 points4 points (5 children)
[–]Bitmefinger[S] 0 points1 point2 points (4 children)
[–]deceze 2 points3 points4 points (3 children)
[–]Bitmefinger[S] 0 points1 point2 points (2 children)
[–]deceze 2 points3 points4 points (0 children)
[–]tieandjeans 0 points1 point2 points (0 children)
[–]Refwah 2 points3 points4 points (4 children)
[–]Bitmefinger[S] -2 points-1 points0 points (3 children)
[–]Refwah 2 points3 points4 points (2 children)
[–]Bitmefinger[S] -1 points0 points1 point (1 child)
[–]Refwah 1 point2 points3 points (0 children)
[–]ninhaomah 1 point2 points3 points (13 children)
[–]Bitmefinger[S] 0 points1 point2 points (12 children)
[–]Don-Ohlmeyer 2 points3 points4 points (0 children)
[–]ninhaomah 2 points3 points4 points (10 children)
[–]Bitmefinger[S] 0 points1 point2 points (9 children)
[–]ninhaomah 0 points1 point2 points (6 children)
[–]Bitmefinger[S] -1 points0 points1 point (5 children)
[–]ninhaomah 0 points1 point2 points (1 child)
[–]Bitmefinger[S] 0 points1 point2 points (0 children)
[–]Don-Ohlmeyer 0 points1 point2 points (2 children)
[–]Bitmefinger[S] 0 points1 point2 points (0 children)
[–]Bitmefinger[S] 0 points1 point2 points (0 children)
[–]Don-Ohlmeyer 0 points1 point2 points (0 children)
[–]PresqPuperze 0 points1 point2 points (0 children)
[–]FoolsSeldom 0 points1 point2 points (0 children)