Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Task 04 (10 points) Write a die rolling class that contains the following methods: - A constructor that accepts an integer representing the number of

Task 04 (10 points)

Write a die rolling class that contains the following methods:

- A constructor that accepts an integer representing the number of sides on the die.

- A get_sides method that will return the number of sides

- A roll method that will return a random number as a result of rolling the die

- A roll_multiple method that takes a number of rolls and returns a list of the results

Class usage

Example output of script

idie = Die(20)

idie.get_sides()

idie.roll()

idie.roll_multiple(4)

20

14

[4,16,1,9]

Task 05 (10 points)

Write a coin flipping class that inherits from the die class. Bet you never thought of a coin as a two sided die. It would contain the following changes:

- The constructor should not take any arguments as a coin usually only has two sides

- A flip method that uses the roll method. If the roll is 1, return "HEADS". if it is 2, return "TAILS"

Class usage

Example output of script

nickle = Coin()

nickle.roll()

nickle.flip()

idie.roll_multiple()

1

TAILS

[1, 1, 2, 1]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Data Analysis Using SQL And Excel

Authors: Gordon S Linoff

2nd Edition

111902143X, 9781119021438

More Books

Students also viewed these Databases questions

Question

Find the derivative. f(x) 8 3 4 mix X O 4 x32 4 x32 3 -4x - x2

Answered: 1 week ago