Question
Please find the required program and output below: Please find the comments against each line for the description: import math # This will import math
Please find the required program and output below: Please find the comments against each line for the description:
import math # This will import math module
def calculate_pi(): # function that return value of m(i) for input i sum = 0 for j in range(0,12): #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 #print the output print ("pi = ", calculate_pi())
Modify the program above program so that it contains a class related to the Leibniz formula. Add additional methods to the class for doing calculations based on the pi attribute. Divide your program into two modules - one which contains your class and another which demonstrates the class methods. Enable a user to enter the number of values to be used in the pi calculation. Be sure your program contains exception handling and has been debugged. It should also launch and be usable under Windows 10 as described in class.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started