Rolling One Die
Random 1 to 6.
Rolling One Die is a free Coding for Kids lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Coding for Kids learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Roll the Dice! 🎲
Let's make the computer roll a dice for us! 🎲 Every roll is a surprise — just like a real game.
Meet random 🎰
Python has a helper called random for surprises. We bring it in with import.
import random
print('random is ready! 🎲')A Random Number 🔢
random.randint(1, 6) picks a number from 1 to 6, just like a dice!
import random
print(random.randint(1, 6))Run It Again 🔁
Run this a few times. You'll get a different number each time. That's the magic! ✨
import random
print(random.randint(1, 6))Save the Roll 📦
Store your roll in a variable so you can use it.
import random
roll = random.randint(1, 6)
print('You rolled', roll)A Dice Emoji 🎲
Make it fun by showing a dice emoji with the number!
import random
roll = random.randint(1, 6)
print('🎲 You got', roll)Did You Roll a 6? 🍀
Use if to check for a lucky six!
import random
roll = random.randint(1, 6)
if roll == 6:
print('Lucky six! 🍀')
else:
print('You rolled', roll)High or Low? ⬆️⬇️
Is your roll big or small? Let's check!
import random
roll = random.randint(1, 6)
if roll >= 4:
print(roll, '- a high roll! ⬆️')
else:
print(roll, '- a low roll ⬇️')Roll Many Times 🔂
Use a loop to roll the dice 5 times in a row!
import random
for i in range(5):
print('🎲', random.randint(1, 6))A Coin Flip Too 🪙
random can also flip a coin — pick from a list!
import random
coin = random.choice(['Heads', 'Tails'])
print('🪙', coin)Roll and Cheer 🥳
Put it together for a fun single roll!
import random
roll = random.randint(1, 6)
print('Rolling... 🎲')
print('You got a', roll, '!')Quick Check ✅
Which line rolls a dice from 1 to 6?
Dice Roller! 🏆
Nice roll! You learned to:
- Import
random🎰 - Roll with
randint(1, 6)🎲 - Save and check your roll 📦
- Roll many times with a loop 🔂
Next: roll two dice and add them! ➕
Frequently asked questions
Is the “Rolling One Die” lesson free?
Yes — the full text of “Rolling One Die” is free to read here on the web, and the Coding for Kids course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Coding for Kids course, upgrade to CoddyKit PRO.
What will I learn in “Rolling One Die”?
Random 1 to 6. You practise Coding for Kids with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Coding for Kids?
No prior experience is required. Coding for Kids on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Rolling One Die” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Coding for Kids lesson?
Yes. Every Coding for Kids lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Rolling One Die
- Rolling Two Dice
- Tracking Dice Points
- First to Twenty