Skip to content

Instantly share code, notes, and snippets.

@coderinboots
Last active October 19, 2020 03:33
Show Gist options
  • Save coderinboots/f44bf5ed6e058c6875e7cf7967f3a33a to your computer and use it in GitHub Desktop.
Save coderinboots/f44bf5ed6e058c6875e7cf7967f3a33a to your computer and use it in GitHub Desktop.
Python program to simulate the dice rolling functionality. For more details, visit https://www.coderinboots.com
import random
roll_again = "yes"
while roll_again == "yes":
# Generates a random number
# between 1 and 6 (including
# both 1 and 6)
dice_value = random.randint(1, 6)
if dice_value == 1:
print("|-----|")
print("| |")
print("| 0 |")
print("| |")
print("|-----|")
if dice_value == 2:
print("|-----|")
print("| 0 |")
print("| |")
print("| 0 |")
print("|-----|")
if dice_value == 3:
print("|-----|")
print("| |")
print("|0 0 0|")
print("| |")
print("|-----|")
if dice_value == 4:
print("|-----|")
print("| 0 0 |")
print("| |")
print("| 0 0 |")
print("|-----|")
if dice_value == 5:
print("|-----|")
print("| 0 0 |")
print("| 0 |")
print("| 0 0 |")
print("|-----|")
if dice_value == 6:
print("|-----|")
print("|0 0 0|")
print("| |")
print("|0 0 0|")
print("|-----|")
x = input("press yes to roll again and any key to exit:")
print("\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment