Question: import math # This will import math module class PI: pi = 0 def calculate_pi(self,n): # function that return value of m(i) for input i
import math # This will import math module class PI: pi = 0 def calculate_pi(self,n): # function that return value of m(i) for input i sum = 0 for j in range(0,n): #iterate loop till 12 times sum = sum + (math.pow(-1,j)/((2*j)+1)) #summation of the Leibniz series pi = 4 * sum return float(pi) #return number def use_pi(self,r,pi): #shows usage of pi attribute in class radius=r area=pi*radius*radius #calculates Circle area return float(area) #print the output obj=PI() n = input('Enter number of values to be used in the pi calculation : ') p=obj.calculate_pi(int(n)) print (" pi = ", p) rad = input(' Enter radius of Circle : ') print (" Area of Circle = ", obj.use_pi(int(rad),p))
hi when i am trying to execute this Python program i am getting error at pi = 0 its showing expected an indented block. Please help me with this asap and Thanks in advancr
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
