Answered step by step
Verified Expert Solution
Link Copied!

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)

  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

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

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions

Question

3 Discuss the value of SPACE analysis.

Answered: 1 week ago

Question

Tell the merits and demerits of Mendeleev's periodic table.

Answered: 1 week ago