Question: solve the problem in python Part 1: Complete Fraction Class Complete the implementation of the Fraction class provided below class Fraction #Constructor. Puts fraction in




solve the problem in python
Part 1: Complete Fraction Class Complete the implementation of the Fraction class provided below class Fraction #Constructor. Puts fraction in simplest form def_init _(self,a,b): self.num a self.den b self.simplify0 #Print Fraction as a String def-str-(self): if self.den 1 return str(self.num) else: return str(self.num)+"/" +str(self.den) #Get the Numerator def getNum(self) return self.num #Get the Denominator def getDen(self) return self.den #Give Numerical Approximation of Fraction def approximate(self) return self.num/self.dern #Simplify fraction def simplify(self) x = self.gcd(self.num,self.den) self.num self.num // x self.den self.den // x #Find the GCD of a and b def gcd(self,a,b) if b-0: return a else return self.gcd(b,a % b) #Complete these methods in lab def-add-(self,other) def__sub_(self,other): def_mul_(self,other) def_truediv__(self,other): def pow (self,exp): return 0 return 0 return O return 0 def_mul(self,other): def_truediv__(self,other) def_pow_(self,exp): return 0 return O return O Complete Implementation of the following methods. All of these methods will return an instance of the Fraction class Add: Subtradt a X a Multipl ax b y by Divide: Power (when k>0 and k is an integer) 0 (8-0(8 k-1 Part 2: Fraction Problems Create a file lab3.py. In this file, use your fraction class to implement functions for each of the following formula. You program should ask the user for the value of n to use in the summations Remember that a summation symbol just tells you to add all the values in a range k 1+2+3+4+5 15 Write functions for each of the below expressions. 1. Harmonic Series: 2. Two: 3. Zero: Zn)-2- 4. Partial Riemann Zeta: Your program will ask for n as input. Compute each of the functions for the given input n. When computing the Riemann Zeta function, print values for b-2,3,4,5,6,7,8 Verify that the input is a valid number. If it is not, ask repeatedly until a valid number is given. Once you have been given a valid input, print out the values of each of the functions in the order H, T, Z, R. See below execution trace for exact layout. Scoring The score for the assignment is determined as follows .10pts - Attended Lab Scoring The score for the assignment is determined as follows 10pts- Attended Lab 10pts Acted as Driver 10pts - Acted as Observer Part 1 o 6pts - Add o 6pts - Subtract o 6pts - Multiply o 6pts - True Divide o 6pts - Power Part2 o 10pts - H Function o 10pts T Function o 10pts - Z Function o 10pts R Function Example Execution Trace Welcome to Fun with Fractions! Enter Number of iterations (integer>C) Bad Input Enter Number of iterations (integer>0) 10 H(10) 7381/2520 H(10)-2.92896825 T(10)-2047/1024 T(101.99902344 Z(10)-1/1024 Z(10)-0.00097656 R(10,2)-1968329/1270080 R(10,2)-1.54976773 R(10,3)-19164113947/16003008000 R(10,3)-1.19753199 R(10,4) 43635917056897/40327580160000 R(10,4)-1.08203658 R(10,5)-105376229094957931/101625502003200000 R(10,5)-1.03690734 R(10,6)-52107472322919827957/51219253009612800000 R(10,6)-1.01734151 R(10,7)-650750820166709327386387/645362587921121280000000 R(10,7)1.00834915 R(10,8)-1632944765723715465050248417/1626313721561225625600000000 R(10,4)-43635917056897/40327580160000 R(10,4)-1.08203658 R(10,5)-105376229094957931/101625502003200000 R(10,5)~ 1.03690734 R(10,6)-52107472322919827957/51219253009612800000 R(10,6)--1.01 734151 R(10,7)-650750820166709327386387/645362587921121280000000 R(10,7)1.00834915 R(10,8)-1632944765723715465050248417/1626313721561225625600000000 R(10,8)"-1.00407735 Fun Facts Each of these series approaches a value when n infinity This series only converges to simple values on even b. (2) 6 4 90 945 g(8)-9450
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
