Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- 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.
- F = ''
- C = ''
- while F_or_C_or_Q != 'exit': #every time it finishes the code block below, it checks.
- F_or_C_or_Q = raw_input('Choose Fahrenheit, Celsius or quit (f,c or q): ')
- print F_or_C_or_Q
- #input and output
- if F_or_C_or_Q == 'Fahrenheit' or F_or_C_or_Q == 'f' or F_or_C_or_Q == 'F':
- F = raw_input('Please input the degrees: ')
- print 'running f'
- print F, ' is ', (int(F) - 32) * 5/9, ' in Celsius.'
- break
- elif F_or_C_or_Q == 'Celsius' or 'c' or 'C':
- C = raw_input('Please input the degrees: ')
- print 'running c'
- print C, ' is ', (int(C) * 9/5) + 32, ' in Fahrenheit.'
- break
- elif F_or_C_or_Q == 'Quit' or 'q' or 'Q':
- print 'Goodbye!'
- exit
- else:
- print 'Please choose f,c or q.'
- if '__name__' == '__main__':
- main()
Add Comment
Please, Sign In to add comment