Dice & Destiny ๐ฒ
Learning: print(), Variables & import random
๐ The Story
This is your very first Python file โ no experience needed! You're going to roll virtual dice, store your player name in a variable, and run a best-of-5 dice tournament. By the end, Python will be doing the work for you, and every run will be different. Ready? Let's roll! ๐ฒ
๐ก Three Things You'll Learn
1. print() makes words appear on screen. 2. Variables store information in labelled boxes. 3. random.randint() rolls a virtual die โ different every time!
๐ฅ๏ธ Do This in PyCharm
-
1Open PyCharm โ File โ Openโฆ โ select the
kids-python-adventure-litefolder โ Trust Project. Then double-clickquick_1_random_dice.py. -
2Press the green โถ Play button (top-right) or Shift + F10. Watch the Console at the bottom fill with dice rolls!
-
3Find
# TODO #1โ change"Adventurer"to YOUR name. Run again โ the dice rolls now include your name! -
4Find
# TODO #2โ changerandint(1, 6)to a different number. Try100for a 100-sided die! -
5Find
# TODO #3โ replace the 5 random events with YOUR OWN. Run it 3 times to see different events appear!
๐ What to Look For in PyCharm
In the Console panel at the bottom, watch for:
- โ Your name next to the dice rolls
- โ Different numbers every time you press โถ Run
- โ One of your custom random events appearing at the bottom
- โ
The tournament showing who wins each round โ
๐ WINSat the end!
๐ Different output every run = you're using Python like a real programmer!