Chapter 19: Object-oriented programming

Program 19.1, Page number: 414

In [1]:
class Fraction:
        def __init__(self):                     #Class constructor
                self.numerator=0
                self.denominator=0

def main():

        #Creating instance
        myFract=Fraction()
        myFract.numerator=1
        myFract.denominator=3

        print("The Fraction is {0}/{1}".format(myFract.numerator,myFract.denominator))

if __name__=='__main__':
        main()
The Fraction is 1/3