Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Where do I begin with this? I am completely stuck. For the first module, write the pseudocode to process these tasks: (Note: lines beginning with
Where do I begin with this? I am completely stuck.
For the first module, write the pseudocode to process these tasks:
(Note: lines beginning with # are comments with tips for you)
- From the random module import randint to roll each die randomly
- # in pseudocode, import a random function
- # the name is helpful for the next M5-2 assignment
- Define a class called Dice
- In Python, the syntax has a colon after it: class Dice():
- In pseudocode, you can specify it generally or be specific
- Under the class declaration, list the attributes. Here are some tips:
- # attributes are what we know about a single die (dice is plural)
- # self is the first attribute in Python and must always appear first
- # add a num_sides attribute and to set it to 6 for the 6 sides on the dice
- Define a method for roll(self)
- # it describes what happens when we roll a single die
- # in the code, it will look like this example
- def __init__(self, dice_sides=6):
- # in pseudocode, we do not worry about the punctuation
- # just list it as part of your logic
- Under roll(self), return a random int value between 1 and self.dice_sides
- Save this file as M5Lab1ii - you can save it as MS Word or a text file.
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