CHAPTER 1: GETTING STARTED

EXAMPLE ON PAGE:12

In [1]:
 
 
p=1000
n=3
r=8.5
si=p*n*r/100                           #formula for simple interest
print "%f\n" % (si)
255.000000

EXAMPLE ON PAGE:17

In [2]:
 
print "Enter values of p,n,r"
p=eval(raw_input())
n=eval(raw_input())
r=eval(raw_input())
si=p*n*r/100
print "%f\n" % (si)
Enter values of p,n,r
1000
3
8.5
255.000000

Example on page:18

In [3]:
 
print "Enter a number"
num=eval(raw_input())                                     #to take user input
print "Now I am letting you on a secret...\n"
print "You have just entered the number %d\n" % (num)
Enter a number
30
Now I am letting you on a secret...

You have just entered the number 30

EXAMPLE ON PAGE:23

In [4]:
 
a=pow(3,2)                             #(3**2) will also do the same operation
print "%d" % (a)
9