Imagine that you want to define a class for fractional numbers, e.g., %4. Fill in the three blanks in the following code to make it a correct definition of a Fraction class. class Fraction: def _init_(self, numerator, denominator): self.n = numerator = denominator def _str_(self): (str(self.n) + "/" + str(self.d)) def getnum(self): return(self.n) def setnum(self, numerator): self.n = numerator def getden(self): return(self.d) def setden(self, denominator): = denominator self.d, return, self self.d, return, self.d return, print, self.n self.d, print, self.n

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter11: Inheritance And Composition
Section: Chapter Questions
Problem 6PE
icon
Related questions
Question
Imagine that you want to define a class for fractional numbers, e.g., %. Fill in the three blanks in the following code to make
it a correct definition of a Fraction class.
class Fraction:
def _init_(self, numerator, denominator):
self.n = numerator
= denominator
def
str_(self):
_(str(self.n) + "/" + str(self.d))
def getnum(self):
return(self.n)
def setnum(self, numerator):
self.n = numerator
def getden(self):
return(self.d)
def setden(self, denominator):
= denominator
O self.d, return, self
O self.d, return, self.d
return, print, self.n
self.d, print, self.n
lself) return dsetd/self)
MacBook Pro
esc
#3
$
&
2
3
あ
4
う
う
え
7
や
お
や
8.
ゆ
よ
え
お
よ
W
て
E い|R
い
Y
ん
た
す
か
な
に
ら
S
と
D
し
F
は
K
き
ま
つ
to
あ
Transcribed Image Text:Imagine that you want to define a class for fractional numbers, e.g., %. Fill in the three blanks in the following code to make it a correct definition of a Fraction class. class Fraction: def _init_(self, numerator, denominator): self.n = numerator = denominator def str_(self): _(str(self.n) + "/" + str(self.d)) def getnum(self): return(self.n) def setnum(self, numerator): self.n = numerator def getden(self): return(self.d) def setden(self, denominator): = denominator O self.d, return, self O self.d, return, self.d return, print, self.n self.d, print, self.n lself) return dsetd/self) MacBook Pro esc #3 $ & 2 3 あ 4 う う え 7 や お や 8. ゆ よ え お よ W て E い|R い Y ん た す か な に ら S と D し F は K き ま つ to あ
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Developing computer interface
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning