85.1k views
4 votes
Write a program that will simulate rolling two dice ( numbers 1 - 6 )

Ask the user how many rolls they want, then using a loop simulate that many dice rolls. Count the number of times the dice land on double 6's and print that total count at the end of the loop.

1 Answer

2 votes

import random

rolls = int(input("How many times do you want to roll the dice? "))

i = 0

total_count = 0

while i < rolls:

die1 = random.randint(1,6)

die2 = random.randint(1,6)

if die1 == 6 and die2 == 6:

total_count += 1

i += 1

print("The dice landed on double 6's {} time(s)".format(total_count))

I hope this helps!

User Anthony Compton
by
4.9k points