tubeshowcaseโ—1,157,887 videosโ™ก My collection 0
โ† Learn to Code

Learn to Code10:06

Code a dice roller program in 10 minutes! ๐ŸŽฒ

Bro Code โ†—

From the creator

#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}")

Published 2022-11-16 ยท Watch on YouTube โ†—
Availability and playback restrictions are controlled by the original channel.

Keep exploring Learn to Code