Advertisement
Guest User

Untitled

a guest
Jul 31st, 2015
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.15 KB | None | 0 0
  1. #---Program by Zakar H.---#
  2. #--- TO DO ---#
  3. #1. Fix equations for rankine,delisle, newton, reaumer, and romer.
  4. #2. Code seems repetitive. Maybe use arrays, functions or dictionary.
  5.  
  6. #Provides an introduction to the game
  7. print("ZvH Temperature Convertorn")
  8.  
  9. #Lets user know what values to enter for the conversion type
  10. def convertor():
  11. print("What temperature are you converting from?")
  12. print("Enter 1 for CelciusnEnter 2 for FahrenheitnEnter 3 for KelvinnEnter 4 for Rankine")
  13. print("Enter 5 for DelislenEnter 6 for NewtonnEnter 7 for ReaumernEnter 8 for Romer")
  14. #Gets user input for conversion type
  15. user_input = input('''''')
  16.  
  17. #If 1 is selected it starts conversion from Celcius
  18. if user_input == ("1"):
  19. def celsius():
  20. print("nWhat temperature are you converting too?")
  21. print("Enter 1 for CelciusnEnter 2 for FahrenheitnEnter 3 for KelvinnEnter 4 for Rankine")
  22. print("Enter 5 for DelislenEnter 6 for NewtonnEnter 7 for ReaumernEnter 8 for Romer")
  23. #Gets user input for converting
  24. type = input('''''')
  25. #COnverts to celcius
  26. if type == ("1"):
  27. temp = int(input('''nType the value for conversion.n'''))
  28. print("nThe conversion calculated")
  29. print(temp)
  30. #Converts to fahrenheit
  31. elif type == ("2"):
  32. temp = int(input('''nType the value for conversion.n'''))
  33. fahrenheit = temp * (9.0/5.0) + 32
  34. print("nThe conversion calculated")
  35. print(fahrenheit)
  36. #Converts to Kelvin
  37. elif type == ("3"):
  38. temp = int(input('''nType the value for conversion.n'''))
  39. kelvin = temp + 273.15
  40. print("nThe conversion calculated")
  41. print(kelvin)
  42. #Converts to Rankine
  43. elif type == ("4"):
  44. temp = int(input('''nType the value for conversion.n'''))
  45. rankine = (temp + 273.15) * (9.0/5.0)
  46. print("nThe conversion calculated")
  47. print(rankine)
  48. #Converts to Delisle
  49. elif type == ("5"):
  50. temp = int(input('''nType the value for conversion.n'''))
  51. delisle = (100 - temp) * (3.0/2.0)
  52. print("nThe conversion calculated")
  53. print(delisle)
  54. #Converts to Newton
  55. elif type == ("6"):
  56. temp = int(input('''nType the value for conversion.n'''))
  57. newton = temp * (33.0/100.0)
  58. print("nThe conversion calculated")
  59. print(newton)
  60. #Converts to Reaumur
  61. elif type == ("7"):
  62. temp = int(input('''nType the value for conversion.n'''))
  63. reaumur = temp * (4.0/5.0)
  64. print("nThe conversion calculated")
  65. print(reaumur)
  66. #Converts to Romer
  67. elif type == ("8"):
  68. temp = int(input('''nType the value for conversion.n'''))
  69. romer = temp * (9.0/5.0) + 7.5
  70. print("nThe conversion calculated")
  71. print(romer)
  72. celsius()
  73.  
  74. #If 2 is selected it starts conversion from Fahrenheit
  75. if user_input == ("2"):
  76. def fahrenheit():
  77. print("nWhat temperature are you converting too?")
  78. print("Enter 1 for CelciusnEnter 2 for FahrenheitnEnter 3 for KelvinnEnter 4 for Rankine")
  79. print("Enter 5 for DelislenEnter 6 for NewtonnEnter 7 for ReaumernEnter 8 for Romer")
  80. #Gets user input for converting
  81. fahrenheit_type = input('''''')
  82. #Converts to celcius
  83. if fahrenheit_type == ("1"):
  84. temp = int(input('''nType the value for conversion.n'''))
  85. fahrenheit = (temp - 32) * (5.0/9.0)
  86. print("nThe conversion calculated")
  87. print(fahrenheit)
  88. #Converts to fahrenheit
  89. elif fahrenheit_type == ("2"):
  90. temp = int(input('''nType the value for conversion.n'''))
  91. print("nThe conversion calculated")
  92. print(temp)
  93. #Converts to Kelvin
  94. elif fahrenheit_type == ("3"):
  95. temp = int(input('''nType the value for conversion.n'''))
  96. fahrneheit = (temp + 459.67) * (5.0/9.0)
  97. print("nThe conversion calculated")
  98. print(fahrenheit)
  99. #Converts to Rankine
  100. elif fahrenheit_type == ("4"):
  101. temp = int(input('''nType the value for conversion.n'''))
  102. fahrenheit = temp + 459.67
  103. print("nThe conversion calculated")
  104. print(fahrenheit)
  105. #Converts to Delisle
  106. elif fahrenheit_type == ("5"):
  107. temp = int(input('''nType the value for conversion.n'''))
  108. fahrenheit = (212 - temp) * (5.0/6.0)
  109. print("nThe conversion calculated")
  110. print(fahrenheit)
  111. #Converts to Newton
  112. elif fahrenheit_type == ("6"):
  113. temp = int(input('''nType the value for conversion.n'''))
  114. fahrenheit = (temp - 32) * (11.0/60.0)
  115. print("nThe conversion calculated")
  116. print(fahrenheit)
  117. #Converts to Reaumur
  118. elif fahrenheit_type == ("7"):
  119. temp = int(input('''nType the value for conversion.n'''))
  120. fahrenheit = (temp -32) * (4.0/9.0)
  121. print("nThe conversion calculated")
  122. print(fahrenheit)
  123. #Converts to Romer
  124. elif fahrenheit_type == ("8"):
  125. temp = int(input('''nType the value for conversion.n'''))
  126. fahrenheit = (temp + 32) * (7.0/24.0) + 32
  127. print("nThe conversion calculated")
  128. print(fahrenheit)
  129. fahrenheit()
  130.  
  131. #If 3 is selected it starts conversion from kelvin
  132. if user_input == ("3"):
  133. def kelvin():
  134. print("nWhat temperature are you converting too?")
  135. print("Enter 1 for CelciusnEnter 2 for FahrenheitnEnter 3 for KelvinnEnter 4 for Rankine")
  136. print("Enter 5 for DelislenEnter 6 for NewtonnEnter 7 for ReaumernEnter 8 for Romer")
  137. #Gets user input for converting
  138. kelvin_type = input('''''')
  139. #Converts to celcius
  140. if kelvin_type == ("1"):
  141. temp = int(input('''nType the value for conversion.n'''))
  142. kelvin = temp - 273.15
  143. print("nThe conversion calculated")
  144. print(kelvin)
  145. #Converts to fahrenheit
  146. if kelvin_type == ("2"):
  147. temp = int(input('''nType the value for conversion.n'''))
  148. kelvin = temp * (9.0/5.0) - 489.67
  149. print("nThe conversion calculated")
  150. print(fahrenheit)
  151. #Converts to Kelvin
  152. elif kelvin_type == ("3"):
  153. kelvin = int(input('''nType the value for conversion.n'''))
  154. print("nThe conversion calculatedn")
  155. print(kelvin)
  156. #Converts to Rankine
  157. elif kelvin_type == ("4"):
  158. temp = int(input('''nType the value for conversion.n'''))
  159. kelvin = temp * (9.0/5.0)
  160. print("nThe conversion calculated")
  161. print(kelvin)
  162. #Converts to Delisle
  163. elif kelvin_type == ("5"):
  164. temp = int(input('''nType the value for conversion.n'''))
  165. kelvin = (375.15 - temp) * (3.0/2.0)
  166. print("nThe conversion calculated")
  167. print(kelvin)
  168. #Converts to Newton
  169. elif kelvin_type == ("6"):
  170. temp = int(input('''nType the value for conversion.n'''))
  171. kelvin = (temp - 273.15) * (33.0/100.0)
  172. print("nThe conversion calculated")
  173. print(kelvin)
  174. #Converts to Reaumur
  175. elif kelvin_type == ("7"):
  176. temp = int(input('''nType the value for conversion.n'''))
  177. kelvin = (temp - 273.15) * (4.0/5.0)
  178. print("nThe conversion calculated")
  179. print(kelvin)
  180. #Converts to Romer
  181. elif kelvin_type == ("8"):
  182. temp = int(input('''nType the value for conversion.n'''))
  183. kelvin = (temp - 273.15) * (21.0/40.0) + 7.5
  184. print("nThe conversion calculated")
  185. print(romer)
  186. kelvin()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement