Answer to Question #35357 in Python for Kevin
How would I go about typing in the formula for the volume of an n-ball found here http://en.wikipedia.org/wiki/Volume_of_an_n-ball
math.pi**(float(n)/2) / math.gamma(float(n)/2+1) * (R**n)
For Python 3.x:
volume = math.pi**(n/2) / math.gamma(n/2+1) * (R**n)
The difference is in the conversion of the integer n to the real value variable.
Need a fast expert's response?Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!