![]() |
Home | Accounts | Setup | Verify | Play | Hacks |
Stimulations
popcorn and homework hacks for Stimulations
Popcorn Hack #1: Brainstorm
-
What do you think a random algorithm is? What would be reason to use random algorithms in real-life coding situations? What kind of questions do you think College Board will ask regarding Random Algorithms?
-
A random algorithm is a set of steps in coding that uses chance or unpredictability to make decisions or create results. Instead of doing the same thing every time, it might choose a different path each time it runs. Random algorithms can be helpful in real-life coding for things like creating games, shuffling music playlists, or generating passwords. They make programs less predictable and more dynamic. The College Board might ask questions about how random algorithms work, when to use them, or how they affect the output of a program. They could also give code and ask you to figure out the possible outcomes.
Popcorn Hack #2
- Copy and Paste this code into a Python cell in your jupyter notebook, change the types of activities, and see which activity you created gets chosen. Once everyone is done, share your results!
# Step 1: Define a list of activities (you can change these!)
import random
activities = [
'Play basketball',
'Practice coding',
'Take a walk outside',
'Do 10 push-ups',
'Watch a science video',
'Organize your room',
'Learn a new dance move',
'Read a comic book',
'Try drawing something cool',
'Listen to a podcast',
'Finish your homework early!'
]
# Step 2: Randomly choose an activity
random_activity = random.choice(activities)
# Step 3: Display the chosen activity
print(f"Today’s random activity: {random_activity}")
Today’s random activity: Watch a science video
Popcorn Hack #3 You and your team are hosting a party. With your team, make a random algorithm to help them decide which person should monitor which activity. Copy and Paste this code into a Python cell in your jupyter notebook, change the names and types of activities, and see which gets chosen.
# Popcorn Hack Number 3: Using a loops in random
# This popcorn hack assigns an activity to each person
import random
hosts = ['Arhaan', 'Manas', 'Ahaan', 'Ahmad', 'Arnav']
activities = ['sports', 'bean bags', 'buffet', 'code, code, code', 'hide n seek']
# Randomly shuffle the list of activities to assign them randomly to the guests
random.shuffle(activities)
# Loop through each guest and assign them a random activity
for i in range(len(hosts)):
print(f"{hosts[i]} will be monitoring {activities[i]}!")
Arhaan will be monitoring bean bags!
Manas will be monitoring code, code, code!
Ahaan will be monitoring hide n seek!
Ahmad will be monitoring buffet!
Arnav will be monitoring sports!
College Board Application: Looking at MCQ’s Let’s look at some previous questions from College Board regarding Big Idea 3.15 Random Values.
- I picked the answer C because 3 is not a possible answer as the first value in the code has to be equal or less than 2 meaning 3 cannot be the first value
Science experiment with 75 percent successful trials
- Which of the following can be used to replace < MISSING CODE > so that the simulation works as intended?
A: RANDOM, open parenthesis 1 comma 100, close parenthesis, equals 25
B: RANDOM, open parenthesis 1 comma 100, close parenthesis, is less than or equal to 25
C: RANDOM, open parenthesis 1 comma 100, close parenthesis, equals 75
D: RANDOM, open parenthesis 1 comma 100, close parenthesis, is less than or equal to 75
- This simulation is trying to model a science experiment where 75% of trials are successful and 25% are unsuccessful. To simulate that, we use random numbers from 1 to 100—this gives us 100 possible outcomes, which makes percentages easy to work with.
Popcorn Hack 1
- Instead of a dice roll, this time let’s create a number spinner. Use the set up of the dice roll example to simulate a number spinner. Create whatever range of numbers you want and share your range and output with the class when finished!
import random
def spin_number():
return random.randint(1, 20) # You can change this range!
spinner_result = spin_number()
print("Spinner landed on:", spinner_result)
Spinner landed on: 19
Popcorn Hack #2 Use the same code from the Rock, Paper, Scissors simulation. Run the cell in your notebook and when prompted to, type out your choice of the three moves. Share your output with the class!
import random
def play_rock_paper_scissors():
choices = ['rock', 'paper', 'scissors']
computer_choice = random.choice(choices)
user_choice = input("Enter your choice (rock, paper, or scissors): ")
if user_choice not in choices:
print("Invalid choice. Please try again.")
return
print("Computer chose:", computer_choice)
print("You chose:", user_choice)
if user_choice == computer_choice:
print("It's a tie!")
elif (user_choice == 'rock' and computer_choice == 'scissors') or \
(user_choice == 'paper' and computer_choice == 'rock') or \
(user_choice == 'scissors' and computer_choice == 'paper'):
print("You win!")
else:
print("You lose!")
play_rock_paper_scissors()
Computer chose: scissors
You chose: paper
You lose!
Part of Popcorn Hack 2
- rock - lose
- scissors - win
- scissors loss
Which of the following strategies is LEAST likely to provide a more accurate prediction?
A: Gathering data for additional years to try to identify patterns in birth rates
B: Refining the model used in the computer simulation to more closely reflect the data from the past ten years
C: Removing as many details from the model as possible so that calculations can be performed quickly
D: Taking into consideration more information about the community, such as the ages of residents
- Removing details from a model might make it run faster, but it also makes the prediction less accurate because it ignores important information. To improve predictions, models need more relevant data, not less. That’s why C is the least likely to help make better predictions.
Based on the code, which of the following assumptions is made in the simulation?
A: The number of mice increases by 1 each day.
B: The number of mice does not change from day to day.
C: The number of predators increases by 1 each day.
D: The number of predators does not change from day to day.
- The correct answer is D because the number of predators is set once at the beginning and is never updated in the loop. Since the code doesn’t change numPredators during the 365 days, it stays the same the whole time.
Homework Hack 1 - Random Algorithms — Homework Hack 1: Random Team Assignment
import random
students = [
"Alex", "Jordan", "Taylor", "Morgan", "Casey",
"Jamie", "Riley", "Cameron", "Drew", "Skyler",
"Avery", "Peyton", "Quinn", "Reese", "Rowan"
]
teams = {
"Team Thunder": [],
"Team Blaze": [],
"Team Galaxy": []
}
team_names = list(teams.keys())
for student in students:
random_team = random.choice(team_names)
teams[random_team].append(student)
# Print results
for team, members in teams.items():
print(f"\n{team}:")
for member in members:
print(f" - {member}")
Team Thunder:
- Drew
- Skyler
- Reese
Team Blaze:
- Alex
- Morgan
- Peyton
- Quinn
- Rowan
Team Galaxy:
- Jordan
- Taylor
- Casey
- Jamie
- Riley
- Cameron
- Avery
Homeowrk Hack 2 - Random Algorithms — Homework Hack 2: Random Weather Generator
import random
weather_types = ["Sunny", "Cloudy", "Rainy"]
days = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
print("7-Day Weather Forecast:\n")
for day in days:
forecast = random.choice(weather_types)
print(f"{day}: {forecast}")
7-Day Weather Forecast:
Monday: Cloudy
Tuesday: Cloudy
Wednesday: Cloudy
Thursday: Cloudy
Friday: Cloudy
Saturday: Rainy
Sunday: Cloudy
Homework Hack 3 - Simulations — Coffee Shop Queue
import random
customers = ["Customer 1", "Customer 2", "Customer 3", "Customer 4", "Customer 5"]
total_time = 0
print("Coffee Shop Queue Simulation:\n")
for customer in customers:
service_time = random.randint(1, 5)
total_time += service_time
print(f"{customer} was served in {service_time} minutes.")
print(f"\nTotal time to serve all customers: {total_time} minutes.")
Coffee Shop Queue Simulation:
Customer 1 was served in 1 minutes.
Customer 2 was served in 2 minutes.
Customer 3 was served in 2 minutes.
Customer 4 was served in 3 minutes.
Customer 5 was served in 3 minutes.
Total time to serve all customers: 11 minutes.