Hour 4: Understanding Data Types and Keywords

Example 4.1, Page No.60

In [1]:
c1='A'
c2='a'

print "Convert the value of c1 to character : ",c1
print "Convert the value of c2 to character : ",c2
Convert the value of c1 to character :  A
Convert the value of c2 to character :  a

Example 4.2, Page No.61

In [4]:
c1=65
c2=97

print "The character that has numeric value of 65 is:", chr(c1)
print "The character that has numeric value of 97 is:", chr(c2)
The character that has numeric value of 65 is: A
The character that has numeric value of 97 is: a

Example 4.3, Page No.63

In [7]:
c1='A'
c2='a'
print "The Numeric Value of A is:",ord(c1)
print "The Numeric Value of a is:",ord(c2)
The Numeric Value of A is: 65
The Numeric Value of a is: 97

Example 4.4, Page No.65

In [10]:
int_num1=int(32/10)
flt_num1=float(32/10)
int_num2=int(32.0/10)
flt_num2=float(32.0/10)
int_num3=int(32/10.0)
flt_num3=float(32/10.0)

print "The integer divis. of 32/10 is",int_num1
print "The floating-point divis. of 32/10 is",flt_num1

print "The integer divis. of 32.0/10 is",int_num2
print "The floating-point divis. of 32.0/10 is",flt_num2

print "The integer divis. of 32/10.0 is",int_num3
print "The floating-point divis. of 32/10.0 is",flt_num3
The integer divis. of 32/10 is 3
The floating-point divis. of 32/10 is 3.0
The integer divis. of 32.0/10 is 3
The floating-point divis. of 32.0/10 is 3.2
The integer divis. of 32/10.0 is 3
The floating-point divis. of 32/10.0 is 3.2