Preparing And Running A Complete C Program

Example 5.2, Page number: 5.4

In [2]:
import math

p,r,n=10000,10,3
i=r/100.0

f=p*math.pow(1+i,n)
print "The final value (F) is: %.2f" %f
The final value (F) is: 13310.00

Example 5.4, Page number: 5.7

In [3]:
import math

a,b,c=2.0,5.0,3.0
d=math.sqrt(b*b-(4*a*c))
x1=(-b+d)/(2*a)
x2=(-b-d)/(2*a)

print "x1 = %e   x2 = %e" %(x1,x2)
x1 = -1.000000e+00   x2 = -1.500000e+00
In [ ]: