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
Which of the following refers to programs that install themselves on computers without the users' knowledge or permission and sp
defon

Answer:

The correct answer is C "Computer Virus"

Explanation:

Computer virus is a piece of code that install itself in a computer without the knowledge and permission of the user and start replicating itself and as it execute it self also start damaging the computer files.

Computer virus have ability to replicate itself and it attached to files and move from one computer to another with these files when files are transferred.

5 0
4 years ago
Write a program that reads in an integer, and breaks it into a sequence of individual digits. Display each digit on a separate l
Montano1993 [528]

Answer:

The program in Python is as follows:

num = int(input())

for i in str(num):

   print(int(i))

Explanation:

This gets input for the number

num = int(input())

This converts the number to string and iterates through each element of the string

for i in str(num):

This prints individual digits

   print(int(i))

4 0
3 years ago
Technology and Communications Quiz Active 1 Which of the following inventions has had the greatest impact on sound technology? A
liraira [26]

Answer:

B the tape recorder bec half century later made sonorities not only reproducible but also alterable.

6 0
3 years ago
Routing between autonomous systems is referred to as ______ .
Gennadij [26K]

Answer:

The correct answer for the given question is an option(b) i.e "interdomain routing".

Explanation:

The Interdomain Routing algorithm protocol works between the domains. The protocol which is used in the interdomain routing is called as exterior gateway protocol. In the interdomain routing protocols works between the autonomous systems, it means they are taking place in the autonomous networks.

  • Intradomain routing works within the domain. They are not works between the autonomous systems so the option(a) is incorrect.
  • Out-of-domain are neither work in within or between the system so option(d) is incorrect.
6 0
3 years ago
How are PivotCharts different from regular charts?
AnnZ [28]

Answer:

The answer is a on edge2020.

:D have a great day and stay safe <3.

6 0
3 years ago
Other questions:
  • "a web server that is​ specially-built to manage and deliver business intelligence is called a​ _________."
    7·1 answer
  • When do on loop conditions happen? (1 point)
    5·1 answer
  • How do u set up a Wi-Fi network on Android ​
    5·1 answer
  • What the five types of initiatives that are necessary when putting together and implementing an IT strategy
    9·1 answer
  • Why would a team choose to employ a zone defense over a person to person defense?
    8·1 answer
  • You have learned a lot about the types of careers that are involved with building a playground. Create two job descriptions of p
    7·2 answers
  • Examples of applying successful visual design principles to bring a web page together are _________________. (Choose all that ap
    9·1 answer
  • Team members can collaborate on ideas using telepresence. <br> true or false?
    10·1 answer
  • What does a virtual machine emulate?
    14·1 answer
  • Why should you avoid the use of sarcasm, clichés, and idioms in business<br> letters
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!