This Python program simulates rolling a six-sided die using the random library, allowing multiple rolls with simple console input and beginner-friendly code.
import random
def lancia_dado():
"""Simulates rolling a six-sided die."""
return random.randint(1, 6) # Generates a random number between 1 and 6
def main():
print("Welcome to the six-sided dice roll simulator!")
while True:
scelta = input("Do you want to roll the die? (s/n): ")
if scelta.lower() == 's':
risultato = lancia_dado()
print(f"You got: {risultato}")
else:
print("Thank you for using the simulator. Goodbye!")
break
if __name__ == '__main__':
main()LANGUAGE: Python 3.x
DEPENDENCIES: standard library 'random'
CONFIG: no external configuration required