Question: Practical Work Using Jupyter Notebook or other Python development platform, develop an object - oriented application that processes fractions. While you are responsible for the

Practical Work
Using Jupyter Notebook or other Python development platform, develop an object-oriented application that processes fractions. While you are responsible for the application's final design, your application is expected to contain a class called fraction, which represents the general format of a mixed fraction, i.e.\( i \frac{n}{d}\), where \( i \) is an optional integer part, \( n \) is the numerator and \( d \) the denominator. You can assume that all numbers \( i \),\( n \) and \( d \) are integers, and you do not need to check for this. Note that \( d \) must be positive. If \( d \) is zero, the number is undefined. If \( i \) is zero, then \( n \) may be negative, zero, or positive. However, if \( i \) is non-zero (positive or negative),\( n \) must be non-negative, and. If \( n \) is zero, the fractional part does not exist and it reduces to the simple integer \( i \). The general output format will be i.n/d. Within the class, you must write public member function(s) to realize one of the following five tasks. The task to do should be determined by a hash function, \(\boldsymbol{h}\)(groupNo, sid1, sid2, sid3), taking inputs from the group number (a number of two digits), and the numeric digits of the sid of the students in the group. The hash function \(\boldsymbol{h}()\) will be provided after the groups are formed.
Tasks
1) The member function + performs the addition with another fraction and returns the result as a fraction. This is realized by implementing adc () inside the class. The result need NOT be in its simplest form (e.g.,\(4/10\) need not be expressed as \(2/5\)).
2) The member function - performs a subtraction with another fraction and returns the result as a fraction. This is realized by implementing sub () inside the class. The result need NOT be in its simplest form (e.g.,\(4/10\) need not be expressed as \(2/5\)).
3) The member function * performs a multiplication with another fraction and returns the result as a fraction. This is realized by implementing \(\mathrm{mu}]\)
() inside the class. The result has to be in its simplest form, i.e., any common factors between the numerator and the denominator should be canceled out. For example, if this fraction has \( n=12\) and \( d=48\), the fraction to be multiplied has \( n=6\) and \( d=16\), the method should return \(12/48\times 6/16=72/768=3/32\), i.e. a fraction of \( n=3\) and \( d=32\) in its simplest form as 24 is the highest common factor (HCF) of 72 and 768.
4) The member function / performs a division with another fraction and returns the result as a fraction. This is realized by implementing truediv () inside the class. The result has to be in its simplest form, i.e., any common factors between the numerator and the denominator should be canceled out. For example, if this fraction has \( n=12\) and \( d=48\), the fraction to be divided has \( n=6\) and \( d=16\), the method should return \(12/48\div 6/16=192/288=2/3\), i.e. a fraction of \( n=2\) and \( d=3\) in its simplest form as 96 is the highest common factor (HCF) of 192 and 288. It can be assumed that the divisor is not zero.
5) The member function @ performs a comparison with another fraction. It returns the integer value 0 if the other fraction is the same in value. It returns the integer value -1 if the other fraction is bigger (i.e. this fraction is smaller). It returns the integer value 1 if the other fraction is smaller (i.e. this fraction is bigger). This is realized by implementing matmul () inside the class.
Some sample program lines and execution results (for reference only):
```
f1= fraction(2,3,4)\ f5= fraction(1,11,12)
f2= fraction(1,3,6) f6= fraction(2,19,24)
f3= fraction(-2,3,4){7= fraction(-1,11,12)
f4= fraction(-1,3,6){
print("{}+{}={}".format(f1,f2,f1+ f2)) print("{} @ {}={}".format(f5,f6,f5@f6))
print("{}+{}={}".format(f1,f4,f1+ f4)) print("{} @ {}={}".format(f5,f8,f5@f8))
print("{}+{}={}".format(f3,f2,f3+ f2)) print("{} @ {}={}".format(f7,f6,f7@f6))
print("{}+{}={}".format(f3,f4,f3+ f4)) print("{} @ {}={}".format(f7,f8,f7@f8))
...\..
f9= fraction(1,12,48)
p =3
print("{}**{}={}".format(f9,p,f9** p))
print("{}/{}={}".format(f3,f2,f3/ f2))
print("{}/{}={}".format(f3,f4,f3/ f4))
``````
2.3/4+1.3/6=4.1/4
2.3/4+-1.3/6=1.1/4
-2.3/4+1.3/6=-1.1/4
-2.3/4+-1.3/6=-4.1/4
2.3/4-1.3/6=1.1/4
2.3/4--1.3/6=4.1/4
-2.3/4-1.3/6=-4.1/4
-2.3/4--1.3/6=-1.1/4
2.3/4*1.3/6=4.1/8
2.3/4*-1.3/6=-4.1/8
-2.3/4*1.3/6=-4.1/8
-2.3/4*-1.3/6=4.1/8
2.3/4/1.3/6=1.5/6
2.3/4/-1.3/6=-1.5/6
-2.3/4/1.3/6=-1.5/6
-2.3/4/-1.3/6=1.5/6
1.11/12 @ 2.19/24=-1
1.11/12 @ -2.19/24=1
-1.11/12 @ 2.19/24=-1
-1.11/12 @ -2.19/24=1
3.4/12 @ 3.2/8=1
3.4/12 @ -3.2/8=1
-3.4/12

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!