Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # credit for this goes to the author
- # of The Python Standard Library by example
- # Jesse Noller, Python Core Developer and PSF Board Member
- # Book can be purchased on amazon, it is also
- # on the oreilly bookshelf and may be at your
- # library. I'm only reprinting the code example
- # here because I'm working on this stuff as a
- # student of the Python Programming language.
- # Thanks Jesse Noller for such a good book.
- import decimal
- a = decimal.Deciaml('5.1')
- b = decimal.Decimal('3.14')
- c = 4
- d = 3.14
- print 'a =', repr(a)
- print 'b =', repr(b)
- print 'c =', repr(c)
- print 'd =', repr(d)
- print
- print 'a + b =', a + b
- print 'a - b =', a - b
- print 'a * b =', a * b
- print 'a / b =', a / b
- print
- print 'a + c =', a + c
- print 'a - c =', a - c
- print 'a * c =', a * c
- print 'a / c =', a / c
- print
- print 'a + d =',
- try:
- print a + d
- except TypeError, e:
- print e
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement