Answered step by step
Verified Expert Solution
Question
1 Approved Answer
you will write a program which does the following: Creates two instances of a die (i.e. a pair of dice). It will roll each of
you will write a program which
does the following:
Creates two instances of a die (i.e. a pair of dice).
It will roll each of the dice
It will retrieve the current face-up values of the dice.
It will display each of the dice after they have been rolled.
It will also display the sum of the two dice.
Finally, it will ask you if youd like to roll the dice again. Write this in python, it is similar to the coin class below
1 inport randon The Coin elasa sinalates a eoin ehat ean # be flipped. 6 elass Coin: eniEethod initializes the 9sideup data attribute with 'Beads". 10 11 de init lf 12 13 14 15 16 17 10 19 20 21 selt..-side:ap Beads. " The toss nethod generates a randon nanber in tho range of 0 through 1. If the number is o, thea sideup is set to Heads # Otherwise, sidaup is set toTails'. def tosa(self) it 1 ) "Heads. randon. rardint [o, -- self.--aldeup else1 self. ideup-Taile 23 24 25 The get eiaup nethod returns the value 2 reterenced by eideup 27 det get sideuptself) 29 return self.sidoup
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