³ò Yp½Hc@sIdZd„Zd„Zd„Zd„Zd„Zd„Zd„ZdS( sqFraction library. This defines a Fraction data structure and some basic operations. Sean Ho for CMPT14x example cCs ||fS(scReturn a new fraction object. pre: numer and denom must be integers; denom cannot be zero. ((tnumertdenom((s#/home/seanho/twu/python/fraction.pytcreatescCs|dS(sReturn the top of the fraction.i((tfrac((s#/home/seanho/twu/python/fraction.pytget_n scCs|dS(s"Return the bottom of the fraction.i((R((s#/home/seanho/twu/python/fraction.pytget_dscCsdt|ƒt|ƒfS(s-Return a string representation of a fraction.s%d / %d(RR(R((s#/home/seanho/twu/python/fraction.pyt to_stringscCs*t|ƒt|ƒt|ƒt|ƒfS(sZMultiply two fractions. Does not reduce the result (i.e., cancel common factors). (RR(tf1tf2((s#/home/seanho/twu/python/fraction.pytmultscCs5t|ƒdjo ddSnt|ƒt|ƒfS(sReturn the reciprocal fraction.ii(RR(R((s#/home/seanho/twu/python/fraction.pytinverts cCst|t|ƒƒS(sDivide two fractions: f1/f2.(R R (RR((s#/home/seanho/twu/python/fraction.pytdivide%sN(t__doc__RRRRR R R (((s#/home/seanho/twu/python/fraction.pyss