Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #---Program by Zakar H.---#
- #--- TO DO ---#
- #1. Fix equations for rankine,delisle, newton, reaumer, and romer.
- #2. Code seems repetitive. Maybe use arrays, functions or dictionary.
- #Provides an introduction to the game
- print("ZvH Temperature Convertorn")
- #Lets user know what values to enter for the conversion type
- def convertor():
- print("What temperature are you converting from?")
- print("Enter 1 for CelciusnEnter 2 for FahrenheitnEnter 3 for KelvinnEnter 4 for Rankine")
- print("Enter 5 for DelislenEnter 6 for NewtonnEnter 7 for ReaumernEnter 8 for Romer")
- #Gets user input for conversion type
- user_input = input('''''')
- #If 1 is selected it starts conversion from Celcius
- if user_input == ("1"):
- def celsius():
- print("nWhat temperature are you converting too?")
- print("Enter 1 for CelciusnEnter 2 for FahrenheitnEnter 3 for KelvinnEnter 4 for Rankine")
- print("Enter 5 for DelislenEnter 6 for NewtonnEnter 7 for ReaumernEnter 8 for Romer")
- #Gets user input for converting
- type = input('''''')
- #COnverts to celcius
- if type == ("1"):
- temp = int(input('''nType the value for conversion.n'''))
- print("nThe conversion calculated")
- print(temp)
- #Converts to fahrenheit
- elif type == ("2"):
- temp = int(input('''nType the value for conversion.n'''))
- fahrenheit = temp * (9.0/5.0) + 32
- print("nThe conversion calculated")
- print(fahrenheit)
- #Converts to Kelvin
- elif type == ("3"):
- temp = int(input('''nType the value for conversion.n'''))
- kelvin = temp + 273.15
- print("nThe conversion calculated")
- print(kelvin)
- #Converts to Rankine
- elif type == ("4"):
- temp = int(input('''nType the value for conversion.n'''))
- rankine = (temp + 273.15) * (9.0/5.0)
- print("nThe conversion calculated")
- print(rankine)
- #Converts to Delisle
- elif type == ("5"):
- temp = int(input('''nType the value for conversion.n'''))
- delisle = (100 - temp) * (3.0/2.0)
- print("nThe conversion calculated")
- print(delisle)
- #Converts to Newton
- elif type == ("6"):
- temp = int(input('''nType the value for conversion.n'''))
- newton = temp * (33.0/100.0)
- print("nThe conversion calculated")
- print(newton)
- #Converts to Reaumur
- elif type == ("7"):
- temp = int(input('''nType the value for conversion.n'''))
- reaumur = temp * (4.0/5.0)
- print("nThe conversion calculated")
- print(reaumur)
- #Converts to Romer
- elif type == ("8"):
- temp = int(input('''nType the value for conversion.n'''))
- romer = temp * (9.0/5.0) + 7.5
- print("nThe conversion calculated")
- print(romer)
- celsius()
- #If 2 is selected it starts conversion from Fahrenheit
- if user_input == ("2"):
- def fahrenheit():
- print("nWhat temperature are you converting too?")
- print("Enter 1 for CelciusnEnter 2 for FahrenheitnEnter 3 for KelvinnEnter 4 for Rankine")
- print("Enter 5 for DelislenEnter 6 for NewtonnEnter 7 for ReaumernEnter 8 for Romer")
- #Gets user input for converting
- fahrenheit_type = input('''''')
- #Converts to celcius
- if fahrenheit_type == ("1"):
- temp = int(input('''nType the value for conversion.n'''))
- fahrenheit = (temp - 32) * (5.0/9.0)
- print("nThe conversion calculated")
- print(fahrenheit)
- #Converts to fahrenheit
- elif fahrenheit_type == ("2"):
- temp = int(input('''nType the value for conversion.n'''))
- print("nThe conversion calculated")
- print(temp)
- #Converts to Kelvin
- elif fahrenheit_type == ("3"):
- temp = int(input('''nType the value for conversion.n'''))
- fahrneheit = (temp + 459.67) * (5.0/9.0)
- print("nThe conversion calculated")
- print(fahrenheit)
- #Converts to Rankine
- elif fahrenheit_type == ("4"):
- temp = int(input('''nType the value for conversion.n'''))
- fahrenheit = temp + 459.67
- print("nThe conversion calculated")
- print(fahrenheit)
- #Converts to Delisle
- elif fahrenheit_type == ("5"):
- temp = int(input('''nType the value for conversion.n'''))
- fahrenheit = (212 - temp) * (5.0/6.0)
- print("nThe conversion calculated")
- print(fahrenheit)
- #Converts to Newton
- elif fahrenheit_type == ("6"):
- temp = int(input('''nType the value for conversion.n'''))
- fahrenheit = (temp - 32) * (11.0/60.0)
- print("nThe conversion calculated")
- print(fahrenheit)
- #Converts to Reaumur
- elif fahrenheit_type == ("7"):
- temp = int(input('''nType the value for conversion.n'''))
- fahrenheit = (temp -32) * (4.0/9.0)
- print("nThe conversion calculated")
- print(fahrenheit)
- #Converts to Romer
- elif fahrenheit_type == ("8"):
- temp = int(input('''nType the value for conversion.n'''))
- fahrenheit = (temp + 32) * (7.0/24.0) + 32
- print("nThe conversion calculated")
- print(fahrenheit)
- fahrenheit()
- #If 3 is selected it starts conversion from kelvin
- if user_input == ("3"):
- def kelvin():
- print("nWhat temperature are you converting too?")
- print("Enter 1 for CelciusnEnter 2 for FahrenheitnEnter 3 for KelvinnEnter 4 for Rankine")
- print("Enter 5 for DelislenEnter 6 for NewtonnEnter 7 for ReaumernEnter 8 for Romer")
- #Gets user input for converting
- kelvin_type = input('''''')
- #Converts to celcius
- if kelvin_type == ("1"):
- temp = int(input('''nType the value for conversion.n'''))
- kelvin = temp - 273.15
- print("nThe conversion calculated")
- print(kelvin)
- #Converts to fahrenheit
- if kelvin_type == ("2"):
- temp = int(input('''nType the value for conversion.n'''))
- kelvin = temp * (9.0/5.0) - 489.67
- print("nThe conversion calculated")
- print(fahrenheit)
- #Converts to Kelvin
- elif kelvin_type == ("3"):
- kelvin = int(input('''nType the value for conversion.n'''))
- print("nThe conversion calculatedn")
- print(kelvin)
- #Converts to Rankine
- elif kelvin_type == ("4"):
- temp = int(input('''nType the value for conversion.n'''))
- kelvin = temp * (9.0/5.0)
- print("nThe conversion calculated")
- print(kelvin)
- #Converts to Delisle
- elif kelvin_type == ("5"):
- temp = int(input('''nType the value for conversion.n'''))
- kelvin = (375.15 - temp) * (3.0/2.0)
- print("nThe conversion calculated")
- print(kelvin)
- #Converts to Newton
- elif kelvin_type == ("6"):
- temp = int(input('''nType the value for conversion.n'''))
- kelvin = (temp - 273.15) * (33.0/100.0)
- print("nThe conversion calculated")
- print(kelvin)
- #Converts to Reaumur
- elif kelvin_type == ("7"):
- temp = int(input('''nType the value for conversion.n'''))
- kelvin = (temp - 273.15) * (4.0/5.0)
- print("nThe conversion calculated")
- print(kelvin)
- #Converts to Romer
- elif kelvin_type == ("8"):
- temp = int(input('''nType the value for conversion.n'''))
- kelvin = (temp - 273.15) * (21.0/40.0) + 7.5
- print("nThe conversion calculated")
- print(romer)
- kelvin()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement