[Tutor] I need help with Python

Vickram vick1975 at intnet.mu
Tue Sep 23 07:24:08 EDT 2003


Hello there,

Python is really an excellent programming language, in terms of mathematical calculations. I have had a first hand experience of the power of python while using the Mayalib source code for python to calculate mayan dates.

However, i am currently experiencing some problems in writing my own program as i am not a language programmer.

I need to make calculations using very large numbers, unfortunately, i am getting a "ZeroDivisionError: float division" error.

Can you please help me out?

What follows is my program. Its simple and brief, yet it is actually calculating one of the best proven theories in science - special relativity.


import cmath



a = 186282.397

b = 1609.344

c = 365.2421987817

d = 99.9999999999999999995

e = (d*a)/100

beta = ((e*b)**2) / ((a*b)**2)

gamma = 1/math.sqrt(1-beta)

ty = 100000

td = ty*c

print

print "speed of light =",a,"mps"

print "1 mile =",b,"metres"

print "1 year =",c,"days"

print

print "% of c =",d,"%"

print "gamma =",gamma

print

print "normal time = ",ty,"years"

print " ",td,"days"

print

print "time dilation =",ty/round(gamma),"yrs"

print " ",td/gamma,"days"

Thanking you

Vickram
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20030923/dcbfe018/attachment-0001.html


More information about the Tutor mailing list