Chapter 2 : Variables and types

Example 2.1 Page no : 11

In [1]:
'''
example 2.1 page no :11
'''

print "Hello, world." 
print "How are you?" 
Hello, world.
How are you?

Example 2.2 Page no : 11/12

In [2]:
'''
example 2.2 page no : 11/12
'''

print "Goodbye, ";
print "cruel world!" 
Goodbye, 
cruel world!

example 2.3 page no : 14

In [1]:
'''
example 2.3 page no : 14
'''
hour = 11;
minute = 59;
colon = ':';
print "The current time is ",
print hour,colon,minute
The current time is  11 : 59

example 2.4 page no : 16

In [3]:
'''
example 2.4 page no : 16
'''

hour = 11;
minute = 59;
print "Number of minutes since midnight: ",
print hour*60 + minute 
print "Fraction of the hour that has passed: ",
print minute/60
Number of minutes since midnight:  719
Fraction of the hour that has passed:  0
In [ ]: