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
What is a set of javascript statements that result in an action?
AlexFokin [52]

function is the right answer because function is a block of code designed to perform a particular task

4 0
3 years ago
A company organizes all of its client database in order of the amount of money that the account is worth. When a new account is
svet-max [94.6K]

Answer:

The addition and count algorithm

Explanation:

3 0
2 years ago
Hotels and motels that are part of a ________ share a centralized reservation system and a common image, logo or advertising slo
hoa [83]
It is company , I think .
8 0
3 years ago
Telecommunications is the transmission of voice and video as well as data and usually implies transmitting a longer distance tha
saul85 [17]

Answer:

The correct answer to the following question will be "True".

Explanation:

  • Telecommunication seems to be the transmitting by cable, antenna, optical or other electromagnetic networks of signs, commands, letters, words, texts, pictures, and sounds, or knowledge of any kind.
  • This happens when the use of technologies involves the information exchange between participants in the conversation.

Therefore, the given statement is true.

6 0
3 years ago
Which network type uses a coaxial cable to receive its signal?.
olchik [2.2K]

Answer:

fiber optic

Explanation:

thanks youuuui

6 0
2 years ago
Other questions:
  • When using vlookup, the _____argument is optional?
    8·1 answer
  • A software license gives the owner the to use software.
    12·2 answers
  • How should you decide what to wear to an interview? What kind of things should be considered?
    12·1 answer
  • Hello my friends i am trying to reboot my i phone 4 but i could not i tried many ways can u help me
    14·1 answer
  • A group of computers that are interconnected in order to share information or documents is called what?
    13·1 answer
  • Draw a circuit with a 12-volt battery, a 100 ohms resistor in series, and two resistors (each of value 200 ohms) in parallel. Wh
    9·1 answer
  • Which area of government regulations do the Fair Credit and Reporting Act
    8·2 answers
  • [If you were the queen of the world .... What would you change ?]
    14·1 answer
  • What free website can you record videos on, and edit them without money?
    5·2 answers
  • _____is used to organize and modify the properties of the current selection.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!