Answered step by step
Verified Expert Solution
Question
1 Approved Answer
how would you use do 25, 26 and 27 using python self-rank rank self-sult = suit def setRank (seir, rank) self-rank = rank def setsuit
how would you use do 25, 26 and 27 using python
self-rank rank self-sult = suit def setRank (seir, rank) self-rank = rank def setsuit (self, suit) self._suit-suit def getRank (self) return self. rank def getsuit (self) return self._suit def selectAtRandom (self) ## Randomly select a rank and a suit ranks ['2, '3, ', 5', '7',8', 9" 10", Jack", "queen", "ing, "ace" self. rankrandom.choice (ranks) self._suit random.choice (" spades", "hearts", "clubs", "diamonds"]) __str--(self) return (seif._rank + of" self._suit) def 19. import pcard 20. import pcard C-pCard.Playingcard) print (c) c = pcard. PlayingCard() print (c.getRank )) 21. import pcard 22. import pcard C-pCard.Playingcard) ?.setRank ("10") c.setsuit("clubs") print (c) C-pCard. Playingcard c.setsuit("diamonds") print (c.getsuito) 23. import pcard 24. 1mport pcard c = pCard. PlayingCard(' 7 ' ) print (c) c- pCard. PlayingCard(5', "clubs" print (c) 25. Cards Write a program that displays a face card (jack, queen, or king) selected at ran- 26. Cards Write a program that displays a card with suit diamond selected at random 27. Fraction Create a class named Fraction having instance variables for numerator and dom. Use the class pCard defined above. Use the class pCard defined above. denominator, and a method that reduces a fraction to lowest terms by dividing the numerator and denominator by their greatest common divisor. (Exercise 17 of Sec- tion 3.3 gives an algorithm for calculating the greatest common divisor of two num bers) Save the class in the file traction.py. Note: This class will be used in Exercis es 28 through 30
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started