6:CONSTANTS,VARIABLES

6.3.1,page number:140

In [1]:
m=4
n=6
p=8
result = m+n
print "m+n=",result
result = int (m/n)
print "m/n=",result
result = m*p
print "m*p=",result
m+n= 10
m/n= 0
m*p= 32

6.3.2,page number:141

In [2]:
m = 4
n = 6
p = 8
result= round(m+n-p*m+p/n,0)
print "m=",m,",n=",n,",p=",p
print "m + n - p * m + p / n = ",result
m= 4 ,n= 6 ,p= 8
m + n - p * m + p / n =  -21.0

6.3.3,page number:142

In [3]:
m = 4
n = 6
print " 6 mod 4 = ",n%m
print "The modulus operator is : %"
 6 mod 4 =  2
The modulus operator is : %

6.3.4,page number:142

In [4]:
m = -4
n = 6
p = 8
print "m=",m," n=",n," p=",p
print "gives"
m=-m
n=-n
p=-p
print "m=",m," n=",n," p=",p
m= -4  n= 6  p= 8
gives
m= 4  n= -6  p= -8