Our final lab will be a pairs programming lab.

We will be implementing various methods in the Fractions class I introduced in class, to be assigned at lab time.

Here is the base code:

class Fraction:


    def __init__(self, top, bottom):


        self.num = top        # the numerator is on top

        self.den = bottom     # the denominator is on the bottom


    def __str__(self):

        return str(self.num) + "/" + str(self.den)


    def getNum(self):

        return self.num


    def getDen(self):

        return self.den


myfraction = Fraction(3, 4)

print(myfraction)


Last modified: Tuesday, October 24, 2017, 1:11 PM