Hacks
Yay!
(1) Reflection
Thorough notes or summary that reflects understanding of today's lesson.
(2) Multiple Choice
- 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.
- 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
- 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
-
What is the advantage of using libraries?
-
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!")
(4) Coding Challenges!
REQUIRED: Create programs in python to complete the two task</p>
EXTRA-CREDIT OPPORTUNITY: 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: 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.