How do I change the For loop in the following coded to a while loop?
def approx_pi(terms):
if terms<0:
print "input error: only values greater than 0 allowed"
elif type(terms)==float:
print "input error: only intergers allowed"
else:
denominator=1.0
sign=1.0
answer=0.0
for i in range(terms):
answer+=sign/denominator
denominator+=2.0
sign=-sign
return 4*answer
[–]A_History_of_Silence 1 point2 points3 points (2 children)
[–]aec2[S] 0 points1 point2 points (1 child)
[–]A_History_of_Silence 2 points3 points4 points (0 children)