Chapter 3: Operators and Expressions

Example 3.13, Page number: 3.9

In [1]:
import ctypes as ct

print "interger  : ",ct.sizeof(ct.c_int())
print "float     : ",ct.sizeof(ct.c_float())
print "double    : ",ct.sizeof(ct.c_double())
print "character : ",ct.sizeof(ct.c_char())
interger  :  4
float     :  4
double    :  8
character :  1

Example 3.30, Page number: 3.19

In [3]:
print "for the equation ax^2+bx+c \n"

a=2
b=6
c=3

root=(b*b-4*a*c)**0.5
x1=(-b + root)/(2*a)
x2=(-b - root)/(2*a)

print "x1=",x1
print "x2=",x2
for the equation ax^2+bx+c 

x1= -0.633974596216
x2= -2.36602540378

Example 3.31, Page number: 3.20

In [2]:
lower="l"
upper=lower.upper()
print upper
L