import random
dice_drawings = {
1: ("┌─────────┐",
"│ │",
"│ ● │",
"│ │",
"└─────────┘"),
2: ("┌─────────┐",
"│ ● │",
"│ │",
"│ ● │",
"└─────────┘"),
3: ("┌─────────┐",
"│ ● │",
"│ ● │",
"│ ● │",
"└─────────┘"),
4: ("┌─────────┐",
"│ ● ● │",
"│ │",
"│ ● ● │",
"└─────────┘"),
5: ("┌─────────┐",
"│ ● ● │",
"│ ● │",
"│ ● ● │",
"└─────────┘"),
6: ("┌─────────┐",
"│ ● ● │",
"│ ● ● │",
"│ ● ● │",
"└─────────┘")
}
# rollit = input("Roll the dice? (y/N): ").lower()
# while rollit == "y":
# dice1 = random.randint(1,6)
# dice2 = random.randint(1,6)
# print("Dices rolled. Results are {} and {}.".format(dice1, dice2))
# print("\n".join(dice_drawings[dice1]))
# print("\n".join(dice_drawings[dice2]))
# rollit = input("Roll the dice? (y/N): ").lower()
######################################################
# for more than 2 dices, use the following
no_of_rolls = int(input("How many dices do you want to roll? "))
rolls_results = []
for i in range(no_of_rolls):
rolls_results.append(random.randint(1,6))
print("The dice results are",rolls_results)
# for i in rolls_results:
# print("\n".join(dice_drawings[i]))
# the above 2 lines can be replace with the following, result will be the same
for i in range(no_of_rolls):
for art in dice_drawings.get(rolls_results[i]):
print(art)
# to print the dice drawings horizontally, use the following
# for line in range(5):
# for rolls in rolls_results:
# print(dice_drawings[rolls][line], end="")
# print()
Comments
Post a Comment
Write something to CodeWithAbdur!