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
Question 2 of 10
horrorfan [7]

Answer:

Lowest Level; Machine Language.

Explanation:

The lowest level of a computer is machine language, which are strings of 0's and 1's in bits, and it's possible to perform tasks at this level. It's however difficult to do and humans created <em>Assembly</em>; a type of low level programming language to be readable, and converts to machine language so that we don't have to work in binary.

4 0
2 years ago
Everfi module 7 answers
Nat2105 [25]
What is the question?
7 0
2 years ago
On a wireless network use _____ to ensure that only authorized client computers are able to access the wireless network.
grigory [225]

Answer:

That

your answer

MAC address filtering

5 0
2 years ago
During the troubleshooting of a pc that will not boot, it is suspected that the problem is with the ram modules. the ram modules
Damm [24]
The modules were somehow disconnected
8 0
3 years ago
Someone plzzzz help me
IgorC [24]

Answer:

Data base

Explanation:

Database holds all your information.

8 0
3 years ago
Other questions:
  • The conventional wisdom concerning the security frameworks of domains is that it is always preferable for an organization to cre
    7·1 answer
  • * Declare a variablecalled "car" of type "Car", and initialise its value to a new instance of the "Car"class.
    9·1 answer
  • What is daemontools pakage in qmail?
    14·1 answer
  • A chef writing up her famed recipe for beef stew realizes she has switched parsley and oregano everywhere in the recipe. The che
    13·1 answer
  • A group of computers that are interconnected in order to share information or documents is called a _____.
    7·1 answer
  • You have a large TCP/IP network and want to keep a host's real time clock synchronized. What protocol should you use?
    10·1 answer
  • A student wants an algorithm to find the hardest spelling word in a list of vocabulary. They define hardest by the longest word.
    9·1 answer
  • Algorithm to calculate the area of a square.​
    6·1 answer
  • (Please answer both parts, please)
    8·2 answers
  • ASAP BRAINLIEST!!!
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!