Last active
October 19, 2020 03:33
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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