• ๐Ÿ“š Homeworks & Creative Tasks (Python, Pick 1)
    • โœจ Task 1: Simple Loot Box
    • ๐ŸŽฒ Task 2: Dice Rolling Counter
    • ๐Ÿ“– Task 3: Random Story Generator
    • โš–๏ธ Task 4: Basic Fairness Test

๐Ÿ“š Homeworks & Creative Tasks (Python, Pick 1)

โœจ Task 1: Simple Loot Box

Create a basic program that opens 10 loot boxes. Use a slider to change the chance of getting rare items (10% to 90%). Count how many common vs rare items you get. Display the results in a simple list.

๐ŸŽฒ Task 2: Dice Rolling Counter

Roll a 6-sided die 20 times. Keep track of how many times each number (1โ€“6) appears. Show the counts in a simple chart or list. Students can see if numbers appear evenly or not.

๐Ÿ“– Task 3: Random Story Generator

Pick random words from simple lists (character, place, action). Example: "The [knight/wizard/dragon] went to the [castle/forest/cave] and [fought/slept/ate]". Generate 5 random stories with one button click. Show all stories in a list.

โš–๏ธ Task 4: Basic Fairness Test

Roll a die 100 times. Count how many times each number appears. Check if each number appears around 16โ€“17 times (100 รท 6 โ‰ˆ 16.67). Display results: "Fair!" if numbers are close to 16โ€“17, "Maybe unfair?" if very different.

All tasks should use simple JavaScript with Math.random() and basic HTML buttons and displays. No complex statistics or advanced libraries are needed.

# Task 1: Simple Loot Box

def open_loot_boxes(chance_percent):
    rare_count = 0
    common_count = 0
    for _ in range(10):
        if random.random() * 100 < chance_percent:
            rare_count += 1
        else:
            common_count += 1
    print(f"Common Items: {common_count}")
    print(f"Rare Items: {rare_count}")

chance = int(input("Enter chance of rare item (10-90): "))
open_loot_boxes(chance)
# Task 2: Dice Rolling Counter

import random

def roll_dice(times):
    counts = [0]*6
    for _ in range(times):
        roll = random.randint(1, 6)
        counts[roll-1] += 1
    for i, count in enumerate(counts, start=1):
        print(f"{i}: {count}")

roll_dice(20)

# Task 3: Random Story Generator

import random

def generate_stories(num_stories=5):
    characters = ["knight", "wizard", "dragon"]
    places = ["castle", "forest", "cave"]
    actions = ["fought", "slept", "ate"]

    for _ in range(num_stories):
        c = random.choice(characters)
        p = random.choice(places)
        a = random.choice(actions)
        print(f"The {c} went to the {p} and {a}.")

generate_stories()
# Task 4: Basic Fairness Test

import random

def fairness_test():
    counts = [0]*6
    for _ in range(100):
        roll = random.randint(1, 6)
        counts[roll-1] += 1

    print("Counts:", counts)
    expected = 100/6
    if all(abs(c - expected) <= 1 for c in counts):
        print("Fair!")
    else:
        print("Maybe unfair?")

fairness_test()