Question: 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)

  1. From the random module import randint to roll each die randomly
  2. # in pseudocode, import a random function
  3. # the name is helpful for the next M5-2 assignment
  4. Define a class called Dice
  5. In Python, the syntax has a colon after it: class Dice():
  6. In pseudocode, you can specify it generally or be specific
  7. Under the class declaration, list the attributes. Here are some tips:
  8. # attributes are what we know about a single die (dice is plural)
  9. # self is the first attribute in Python and must always appear first
  10. # add a num_sides attribute and to set it to 6 for the 6 sides on the dice
  11. Define a method for roll(self)
  12. # it describes what happens when we roll a single die
  13. # in the code, it will look like this example
  14. def __init__(self, dice_sides=6):
  15. # in pseudocode, we do not worry about the punctuation
  16. # just list it as part of your logic
  17. Under roll(self), return a random int value between 1 and self.dice_sides
  18. 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!