Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 5 Look at the class definition of Die class: 4 pts class Die: def _init_(self): self._value = 1 def getValue(self): return self._value def

  

Question 5 Look at the class definition of Die class: 4 pts class Die: def _init_(self): self._value = 1 def getValue(self): return self._value def roll (self): self._value = random.randrange (1, 7) Make minimal changes to the Die class definition so that the number of sides of the Die can be optionally set in the constructor with the default value of 6. For example, die8 = Die(8) will create an 8-sided die such that every time die8.roll() is called, it sets the __value to a random number between 1 and 8. Note that die = Die() should continue to create a 6-sided die. Question 6 Suppose myData is defined as follows: myData = { [1, 2, 3], 'y' : { 'color': 'blue', 'weight' : 10, 3: (7,8), }, ('a', 'b'): 4, 'z' [123, 456] } Give an expression involving myData that accesses the value 10: Give an expression involving myData that accesses the value 4: 4 pts

Step by Step Solution

There are 3 Steps involved in it

Step: 1

To modify the Die class to allow setting the number of sides ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Java How To Program Late Objects Version

Authors: Paul Deitel, Deitel & Associates

8th Edition

0136123716, 9780136123712

More Books

Students also viewed these Programming questions

Question

How do general controls over access rights affect the sales cycle?

Answered: 1 week ago

Question

What is the mode 6,6,8,9,3,9,6,3

Answered: 1 week ago