Guest User

Untitled

a guest
Jul 16th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.02 KB | None | 0 0
  1. import sys
  2. F_or_C_or_Q = '' #if we run a comparison before this variable has a value, we throw an error. comment out this whole line to see.
  3. F = ''
  4. C = ''
  5.  
  6. while F_or_C_or_Q != 'exit': #every time it finishes the code block below, it checks.
  7.     F_or_C_or_Q = raw_input('Choose Fahrenheit, Celsius or quit (f,c or q): ')        
  8.     print F_or_C_or_Q
  9. #input and output
  10.     if F_or_C_or_Q == 'Fahrenheit' or F_or_C_or_Q == 'f' or F_or_C_or_Q == 'F':
  11.         F = raw_input('Please input the degrees: ')
  12.         print 'running f'
  13.         print F, ' is ', (int(F) - 32) * 5/9, ' in Celsius.'
  14.         break
  15.                
  16.     elif F_or_C_or_Q == 'Celsius' or 'c' or 'C':
  17.         C = raw_input('Please input the degrees: ')
  18.         print 'running c'
  19.         print C, ' is ', (int(C) * 9/5) + 32, ' in Fahrenheit.'
  20.         break
  21.            
  22.     elif F_or_C_or_Q == 'Quit' or 'q' or 'Q':
  23.         print 'Goodbye!'
  24.         exit
  25.        
  26.     else:
  27.         print 'Please choose f,c or q.'
  28.  
  29. if '__name__' == '__main__':
  30.     main()
Add Comment
Please, Sign In to add comment