< Jun Day 2 >
Whiteboard Images
Original Plan
Warm up 1
Warm up 2
Magic 8 Ball
Activity 1 Initial Board
Activity 1 Extended Board
Code Sections
Magic 8 Ball
import random
choice = random.randint(1, 8)
user = input("Enter a question: ")
if(choice == 1):
print("Yes")
elif(choice == 2):
print("Maybe")
elif(choice == 3):
print("It is certainly so")
elif(choice == 4):
print("Ask again")
elif(choice == 5):
print("Possibly")
elif(choice == 6):
print("Maybe not")
elif(choice == 7):
print("Try it")
else:
print("Definitely")
Count Even Numbers
Option 1
count = 0
limit = 100
while(count < limit):
print(count)
count = count + 2
Option 2
count = 0
limit = 100
while(count < limit):
if(count % 2 == 0):
print(count)
count = count + 1
Dice Rolls
import random
ones = 0
twos = 0
threes = 0
fours = 0
fives = 0
sixes = 0
count = 0
limit = input("How many dice should we roll? ")
limit = int(limit)
while(count < limit):
roll = random.randint(1,6)
if(roll == 1):
ones = ones + 1
elif(roll == 2):
twos = twos + 1
elif(roll == 3):
threes = threes + 1
elif(roll == 4):
fours = fours + 1
elif(roll == 5):
fives = fives + 1
else:
sixes = sixes + 1
count = count + 1
print("ones:", ones)
print("twos:", twos)
print("threes:", threes)
print("fours:", fours)
print("fives:", fives)
print("sixes:", sixes)
Prime checker
num = 43
count = 2
flag = True
while(count < num // 2):
if(num % count == 0):
flag = False
count = count + 1
if(flag == True):
print("The number", num, "is a prime number!")
else:
print("The number", num, "is not a prime number!")