Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # import modules
- import time
- import random
- import os
- def throw_dice() -> int:
- """
- A function that represent a six side dice that picks a random number
- from a list of 6 numbers
- :return: int
- """
- return random.choice([1, 2, 3, 4, 5, 6])
- def display_rolling_dice_message():
- """a function to display a animated message"""
- dots = [".", "..", "...", "....", "....."]
- for _ in range(3):
- for num in range(0, 5):
- os.system("cls")
- print(f"Rolling Dices, Please Wait{dots[num]}")
- time.sleep(0.1)
- # display and animate rolling message
- display_rolling_dice_message()
- # clear the console for new message
- os.system("cls")
- # print the result
- print("Your dice roll ended up with:")
- print("--------------------------")
- print("| D1 | D2 | D3 | D4 | D5 |")
- print("--------------------------")
- print(f"| {throw_dice()} | {throw_dice()} | {throw_dice()} | {throw_dice()} | {throw_dice()} |")
- print("--------------------------")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement