View Single Post
Old Feb 6th, 2005, 7:54 PM   #7
arod199113
Programmer
 
arod199113's Avatar
 
Join Date: Feb 2005
Posts: 86
Rep Power: 0 arod199113 is an unknown quantity at this point
Quote:
Originally Posted by Dietrich
There are several ways to use import, here is one example:
[php]
# math sqrt()

import math

print "\nSquare root of integer formatted as float with 4 decimals:"
for value in range(10):
squareRoot = math.sqrt(value)
print "sqrt(%d) = %.4f" % (value, squareRoot)
[/php]

The squareroot function is in module math. Notice how we used math.sqrt(value) to tie the two together. You can avoid the math prefix by using:
from math import sqrt
or if you use several other math functions:
from math import *


ok you cofused me on that
cause im jut a beginer
i guess i know y i havent learned the import just yet :o
arod199113 is offline   Reply With Quote