Answered step by step
Verified Expert Solution
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 ...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