Python Homework

Hello, I have homework in Fraction Python programming. Please, make sure to read the homework very carefully because our instructor stuck in every thing. So, if there is anything is missed, he would give me ZERO. So, please check the red color that I pointed in the paper. I hope also the program is simple and clear and not used from other student, because i he figured out the program is similar to other student, I will fail in the class. I attached the codes for the fraction file program.

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

class Fraction:
def __init__(self, top, bottom):
self.num = top
self.den = bottom
def __str__(self):
return str(self.num) + “/” + str(self.den)
def gcd(self, m, n):
while m % n != 0:
oldm = m
oldn = n
m = oldn
n = oldm % oldn
return n
def __add__(self, other):
newnum = self.num * other.den + \
self.den * other.num
newden = self.den * other.den
common = self.gcd(newnum, newden)
return Fraction(newnum // common, newden // common)
def __eq__(self, other):
firstNum = self.num * other.den
secondNum = other.num * self.den
return firstNum == secondNum
Use the fraction.py file located in the I:\kopp\outbox\CS 222 01\Programming Assignments\Chapter 01
folder. Complete the following:
1. Modify the Constructor for the Fraction class so that GCD is sued to reduce fractions
immediately. This means that the_add__function no longer needs to reduce.
2. Implement the remaining simple arithmetic operators (_sub, mul_, and __truediv_).
3. Implement the remaining relational operators (_gt__ge__ It__le
le__ and __ne_)
4. Modify the constructor for the Fraction class so that it checks to make sure that the numerator
and denominator are both integers. If either is not an integer the constructor should raise an
exception.
Add the following comments to the beginning of the program.
Name:
Your Name
Class and Section: CS 222 01
Assignment:
Program Assignment 04
Due Date:
See above
Date Turned in:
Program Description: You write a short description of what the program will do
When you complete the program, do the following.
1. Create a folder with the following name: ProgramAssignment04
2. Copy your program to this folder
3. Copy the folder to your folder in the I:\kopp\inbox\CS 222 01 folder
class Fraction:
def init__(self, top, bottom):
self. num = top
self.den = bottom
def
str (self):
return str(self.num) + “/” + str(self.den)
def ged(self, m, n):
while mn != 0:
oldm = m
oldn = n
m = oldn
n = oldm & oldn
return n
def
add (self, other):
newnum = self.num * other.den + \
self.den * other.num
newden = self.den * other. den
common = self.gcd (newnum, newden)
return Fraction (newnum // common, newden // common)
def
eq_(self, other):
firstNum = self.num * other.den
secondNum = other.num * self.den
return firstNum == secondNum

Still stressed from student homework?
Get quality assistance from academic writers!

Order your essay today and save 25% with the discount code LAVENDER