lundi 10 septembre 2018

Translating temperature (Fahrenheit and Celsius) in Python 3

So I have this simple program which the user can use to tell where they're from and where they're currently at (Only using the USA and the UK for this). I would like the program to translate the temperature from the usual temperature scale in the country the user is currently in, to the usual temperature scale to the country from which they come from. I'm struggling quite a bit to come up with a reasonable solution for this so I'm open for any suggestions, thanks.

Here's my code so far:

location = input("Where are you from?\n")
uk = ("the UK")
us = ("the USA")
if location == uk:
print("You are from the UK.\n")
elif location == us:
print("You are from the USA.\n")
else:
print("Sadly, I cannot help you.\n")
locationNow = input("Where are you currently at?\n")
if locationNow == uk:
print("You are currently in the UK.\n")
elif locationNow == us:
print("You are currently in the US.\n")
else:
print("Sadly I cannot help you.\n")
temp = input("What is the temperature for tomorrow?\n")

Aucun commentaire:

Enregistrer un commentaire