Q2Comprehension4 Marks30 Apr 2023
Passage
Based on the above data, answer the given subquestions.
rational is a class that represents positive rational numbers. Recall that a rational number x is of the form p/q, where the greatest common divisor of (p, q) is equal to 1, with q != 0. In this case, we will be modeling only positive rationals as a class.
```
class Rational:
def __init__(self, num, den):
self.num = num
self.den = den
self.reduce()
def print_info(self):
if self.den == 1:
print(f'{self.num}')
else:
print(f'{self.num}/{self.den}')
def reduce(self):
for i in range(min(self.num, self.den), 1, -1):
if self.num % i == 0 and self.den % i == 0:
self.num = self.num // i
self.den = self.den // i
break
def divide(self, k):
self.den = self.den * k
self.reduce()
```
What is the output of the following snippet of code?
```
x = Rational(15, 24)
x.divide(5)
x.print_info()
```