Skip to content

Instantly share code, notes, and snippets.

@roman-on
Created April 3, 2020 02:22
Show Gist options
  • Select an option

  • Save roman-on/a0c719b9a5a07208da9ff1d36f87bafc to your computer and use it in GitHub Desktop.

Select an option

Save roman-on/a0c719b9a5a07208da9ff1d36f87bafc to your computer and use it in GitHub Desktop.
Convert Celsius to Fahrenheit and vise versa
# 50F 50f = 10C 10c
temp = str(input("Insert the temperature you would like to convert:"))
a = int(temp[:-1]) # num
b = temp[-1:] # c / C
c = int(temp[:-1]) # num
d = temp[-1:] # f / F
ce = ((5*c-160)//9)
fe = ((9*a+(32*5))//5)
if (b == "C") or (b == "c"):
print(fe, "F")
elif (d == "F") or (d == "f"):
print(ce, "C")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment