1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
34kurt
3 years ago
10

Write a program that rolls two dice until the user gets snake eyes. You should use a loop and a half to do this. Each round you

should roll two dice (Hint: use the randint function!), and print out their values. If the values on both dice are 1, then it is called snake eyes, and you should break out of the loop. You should also use a variable to keep track of how many rolls it takes to get snake eyes.
Sample Run:

Rolled: 6 5
Rolled: 5 2
Rolled: 3 6
Rolled: 6 2
Rolled: 1 2
Rolled: 5 3
Rolled: 1 4
Rolled: 1 1
It took you 8 rolls to get snake eyes.

I have most of the code but when it prints it say you rolled 0 times every time.
import random

# Enter your code here

num_rolls = 0


import random
# Enter your code here

while True:

roll_one = random.randint(1,6)
roll_two = random.randint(1,6)
print ("Rolled: " +str(roll_one) +"," + str(roll_two))
if (roll_one == 1 and roll_two == 1):
print ("it took you " + str(num_rolls) + " rolls")
break

output:
Rolled: 3,5
Rolled: 6,4
Rolled: 2,4
Rolled: 3,6
Rolled: 5,2
Rolled: 1,1
it took you 0 rolls

suppose to say:
It took you (however many rolls) not 0
Computers and Technology
1 answer:
marishachu [46]3 years ago
4 0

import random

num_rolls = 0

while True:

   r1 = random.randint(1, 6)

   r2 = random.randint(1, 6)

   print("Rolled: " + str(r1) + "," + str(r2))

   num_rolls += 1

   if r1 == r2 == 1:

       break

print("It took you "+str(num_rolls)+" rolls")

I added the working code. You don't appear to be adding to num_rolls at all. I wrote my code in python 3.8. I hope this helps.

You might be interested in
A colleague is complaining about the slowness of a desktop computer, and you explain that the slowness is
mr_godi [17]

Answer:

You are explaining a virtual server

I hope this is correct.

Explanation:

A virtual platform is a software based system that can fully mirror the functionality of the platform, it provides full visibility

A virtual server, on the other hand converts one physical server into multiple virtual machines that can each run their own operating system, it is hosted by a offsite dsta center

6 0
2 years ago
Need A girl to play wit I'm bored On xbox btw or just to talk too btw be at least 12​
attashe74 [19]

Answer:

im 13 and im a girl wassup

Explanation:

3 0
3 years ago
Read 2 more answers
In the U.S. a standard mortgage requires a down payment of
Doss [256]
Atleast a minimum of 3%. Brainliest? 
6 0
3 years ago
Write the definition of a class simple. the class has no constructors , methods or instance variables .
Mkey [24]
One is of type int
called hours, initialized to 12, another is of type boolean called
isTicking, initialized to true, and the last one is of type Integer
called diff, initialized to 5.
6 0
3 years ago
Complete the statement below using the correct term.
julia-pushkina [17]

Answer:

im pretty sure it is the implementation phase. But i can't be too sure about it.

5 0
2 years ago
Other questions:
  • Steven is in a meeting and he is sharing a graph on his monitor with fifty other people. So that the others do not need to crowd
    9·1 answer
  • A file name extension provides what information about a file?
    10·2 answers
  • Combination of two or more networks
    15·1 answer
  • What is earning potential?
    10·1 answer
  • Projects used for print and web have different ?
    5·1 answer
  • Why is it uncommon for users to perform searches directly in database tables?
    15·1 answer
  • ANSWER ASAP!!!!!
    10·2 answers
  • What is local technology ? give examples​
    6·1 answer
  • Convert ⅖ pie radian to degree​
    15·1 answer
  • Find the distance between the points.<br><br><br>(5,-2),(-6,-2)
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!