-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathex3.py
28 lines (23 loc) · 768 Bytes
/
ex3.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# */ first, then %, then +-
# % takes modulus
# (1/4) automatically drops decimal
print "I will now count my chickens:"
print "Hens", 25 + 30 / 6
print "Roosters", 100 - 25 * 3 % 4
print "Now I will count the eggs:"
print 3+2+1-5+4%2-1/4+6
print "Is it true that 3+2 < 5-7?"
print 3+2 < 5-7
print "What is 3+2?", 3+2
print "What is 5-7?", 5-7
print "Oh, that's why it's False."
print "How about some more."
print "Is it greater?", 5 > -2
print "Is it greater or equal?", 5 >= -2
print "Is it less or equal?", 5 <= -2
# 53 bits of precision for Python float, eg. 1/10 ~= J/(2**N)
print "Using floats..."
print 20.0/2
#rounding the display of the true machine value
# 0.1 + 0.2 => 0.30000000000000004
# from decimal import Decimal Decimal(2.675) shows exact value