Skip to content

Friday 10/6

Reviewing For Next Week's Quiz

This week's coding questions are posted to canvas: 3a_coding.pdf. Practicing these is likely to be good preparation for next week. The answers to the Canvas portion will be posted this afternoon.

POGIL

Act07-WhileRandom.pdf

Model 1 Code

    i = 0
    while i < 3:
        print("the number is", i)
        i = i + 1
    print("goodbye")

Model 3 Code

guess_number.py

import random

print("Guess my number!")
number = random.randint(1, 100)

guess = 0
while guess != number:
    guess = int(input("Guess: "))
    if guess > number:
        print("Too high!")
    elif guess < number:
        print("Too low!")

print("You got it!")

coin_toss.py

import random

heads = 0
tails = 0
times = 1000000

for _ in range(times):
    if random.random() < 0.5:
        heads += 1
    else:
        tails += 1

heads = round(heads / times * 100, 2)
tails = round(tails / times * 100, 2)

print(f"Head: {heads}%, Tail: {tails}%")