Dice Rolling Simulator Version 2
The Goal: Like the title suggests, this project involves writing a program that simulates rolling dice. When the program runs, it will randomly choose a number between 1 and 6. (Or whatever other integer you prefer — the number of sides on the die is up to you.) The program will print what that number is. It should then ask you if you’d like to roll again. For this project, you’ll need to set the min and max number that your dice can produce. For the average die, that means a minimum of 1 and a maximum of 6. You’ll also want a function that randomly grabs a number within that range and prints it.
Concepts to keep in mind:
- Random
- Integer
- While Loops
_______________________________________________________
import random
from random import randint
def main():
min = 1
max = 6
roll_again = "yes"
while roll_again == "yes" or roll_again == "y":
print("Rolling the dices...")
print("The values are....")
print(random.randint(min, max))
print(random.randint(min, max))
roll_again = input("Roll the dices again?")
if __name__ == '__main__':
main()
Comments
Post a Comment