Course Hive
Search

Welcome

Sign in or create your account

Continue with Google
or
Code a dice roller program in 10 minutes! ๐ŸŽฒ
Play lesson

Python tutorial for beginners ๐Ÿ - Code a dice roller program in 10 minutes! ๐ŸŽฒ

4.0 (0)
8 learners

What you'll learn

This course includes

  • 14.3 hours of video
  • Certificate of completion
  • Access on mobile and TV

Summary

Keywords

Full Transcript

#python #tutorial #course # Here are the Unicode characters I use for drawing the dice. # Youtube has strange spacing, so the ASCII art looks warped in the description. # It should still work if you copy and paste it into PyCharm. # โ— โ”Œ โ”€ โ” โ”‚ โ”” โ”˜ import random dice_art = { 1: ("โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”", "โ”‚ โ”‚", "โ”‚ โ— โ”‚", "โ”‚ โ”‚", "โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜"), 2: ("โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”", "โ”‚ โ— โ”‚", "โ”‚ โ”‚", "โ”‚ โ— โ”‚", "โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜"), 3: ("โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”", "โ”‚ โ— โ”‚", "โ”‚ โ— โ”‚", "โ”‚ โ— โ”‚", "โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜"), 4: ("โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”", "โ”‚ โ— โ— โ”‚", "โ”‚ โ”‚", "โ”‚ โ— โ— โ”‚", "โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜"), 5: ("โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”", "โ”‚ โ— โ— โ”‚", "โ”‚ โ— โ”‚", "โ”‚ โ— โ— โ”‚", "โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜"), 6: ("โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”", "โ”‚ โ— โ— โ”‚", "โ”‚ โ— โ— โ”‚", "โ”‚ โ— โ— โ”‚", "โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜") } dice = [] total = 0 num_of_dice = int(input("How many dice?: ")) for die in range(num_of_dice): dice.append(random.randint(1, 6)) # PRINT VERTICALLY # for die in range(num_of_dice): # for line in dice_art.get(dice[die]): # print(line) # PRINT HORIZONTALLY for line in range(5): for die in dice: print(dice_art.get(die)[line], end="") print() for die in dice: total += die print(f"total: {total}")

Course Hive

Continue this lesson in the app

Install CourseHive on Android or iOS to keep learning while you move.

Related Courses

FAQs

Course Hive
Download CourseHive
Keep learning anywhere