Learning Python: Playing with numbers

""" guess the answers """

print 6 + 12 -3
print 2 * 3.0
print (- - 4)
print 10/3
print 10.0/3.0
print (2+3) *4
print 2 + 3 * 4
print 2**3 + 1
print 2.1 ** 2.0
print 2.2 * 3.0

print ""


""" Guess the answers in your head """

print 3 > 4
print 4.0 > 3.999
print 4 > 4
print 4 > +4
print 2+2 ==4
print True or False
print not False
print 3.0 - 1.0 != 5.0 - 3.0
print 3 > 4 or (2 < 3 and 9 > 10)
print 4 > 5 or 3 < 4 and 9 > 8
print not(4 > 3 and 100 > 6)


""" Guess the answer and type """

print 3 + 5.0, type(3 + 5.0)
print 5/2, type (5/2)
print 5/2 == 5/2.0, type (5/2 == 5/2.0)
print 5/2.0, type (5/2.0)
print round(2.6) #this one worth noting
print int(2.6)
print 2.0 + 5.0, type(2.0 + 5.0)
print 5*2 == 5.0 * 2.0

Output


15
6.0
4
3
3.33333333333
20
14
9
4.41
6.6

False
True
False
False
True
True
True
False
False
True
False
8.0 <type 'float'>
2 <type 'int'>
False <type 'bool'>
2.5 <type 'float'>
3.0
2
7.0 <type 'float'>
True