• ๐Ÿ“š 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.

import random

def open_loot_boxes(chance):
    rare = 0
    common = 0

    for i in range(10):
        if random.random() < chance:
            rare += 1
        else:
            common += 1

    print("Loot Box Results:")
    print("Rare items:", rare)
    print("Common items:", common)

# Example: 30% chance for rare items (change this number between 0.1 and 0.9)
chance_of_rare = 0.3
open_loot_boxes(chance_of_rare)
๐ŸŽ Loot Box Results:
Rare items: 4
Common items: 6