(1) Reflection

Thorough notes or summary that reflects understanding of today's lesson.

(2) Multiple Choice

  1. What does the random(a,b) function generate?

A. A random integer from a to be exclusive

B. A random integer from a to b inclusive.

C. A random word from variable a to variable b exclusive.

D. A random word from variable a to variable b inclusive.

  1. What is x, y, and z in random.randrange(x, y, z)?

A. x = start, y = stop, z = step

B. x = start, y = step, z = stop

C. x = stop, y = start, z = step

D. x = step, y = start, z = stop

  1. Which of the following is NOT part of the random library?

A. random.item

B. random.random

C. random.shuffle

D. random.randint

(3) Short Answer Questions

  1. What is the advantage of using libraries?

  2. Write a thorough documentation of the following code.

import random 

names_string = input("Give me everybody's names, seperated by a comma.")
names = names_string.split(",")

num_items = len(names)

random_choice = random.randint(0, num_items - 1)

person_who_will_pay = names[random_choice]

print(f"{person_who_will_pay} is going to buy the meal today!")
 is going to buy the meal today!

(4) Coding Challenges!

REQUIRED: Create programs in python to complete the two task</p>

  1. Create a program to pick five random names from a list of at least 15 names
  2. Create a program to simulate a dice game where each player rolls two fair dice (6 sides); the player with the greater sum wins

EXTRA-CREDIT OPPORTUNITY:

  1. Create a program to randomly generate one of those 5x5 square CollegeBoard robot courses frequently seen in these lessons. Here are the criteria:
  • No need to create a graphical user interface (output the course in graphical form); that would be too demanding. You can use store your randomizations in variables to be printed, after which you can sketch one instance of your output using any means (handdrawn, google drawings, etc.) to attach to your submission as an image.

  • Your illustration can differ graphically from CollegeBoard's illustrations as long as the robot, its direction, the wall squares, and the goal square are fairly self-evident (ie you can make the goal a present or food instead of a gray square)

You must randomize the following:

  1. Initial direction of the robot (up, down, left, right)
  2. Initial Position of the robot
  3. Goal position
  4. Positions of at least 12 wall/obstacle squares

The latter three must be mutually exclusive (on different squares). This prevents you from generating a course where the robot is on the goal, on a wall square, or the goal is in a wall square

EXTRA X 2: Put safeguards in your program to make sure the robot course is actually possible to complete. This one is tough, so if you manage to do it you're pretty much guaranteed to get 1.0 points. This will not likely be the only way to get a perfect score, however.

</div> </div> </div> </div>