Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: iso-8859-1 -*-
- # calcutron.py
- while True:
- print "(a)dd, (s)ubtract, (m)ultiply, (d)ivide, (q)uit"
- operation = raw_input('Give an operation: ')
- if operation == 'a' or operation == 's' or operation == 'm' or operation == 'd':
- first = float(input('First number: '))
- second = float(input('Second number: '))
- if operation == 'a':
- result = first + second
- print '%.1f' %(result)
- elif operation == 's':
- result = first - second
- print '%.1f' %(result)
- elif operation == 'm':
- result = first * second
- print '%.1f' %(result)
- elif operation == 'd':
- if second == 0:
- print "Cannot divide by zero."
- else:
- result = first / second
- print '%.1f' %(result)
- elif operation == 'q':
- break
- else:
- print "WHAT ARE YOU DOING?"
Add Comment
Please, Sign In to add comment