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
Pls can anyone be so kind and answer this question.....i need the answer urgently
mixas84 [53]

Answer:

so u have to be smaet

Explanation:

8 0
3 years ago
Which of the following best describes how computing devices represent information ​
olganol [36]

Answer:

A system is which a computer is used to turn data into information best describes a computer-based information system.

A text code is a system that uses binary numbers (1s and 0s) to represent characters understood by humans (letters and numerals). y An early text codesystem, called EBCDIC, uses eight-bit codes, but is used primarily in older mainframe systems.

Data processing is simply the conversion of raw data to meaningful information through a process. ... Similar to a production process, it follows a cycle where inputs (raw data) are fed to a process (computer systems, software, etc.) to produce output (information and insights).

The central processing unit consists of electronic circuits that interpret and execute program instructions, as well as communicate with the input, output, and storage devices. It is the central processing unit that actually transforms data into information. Data is the raw material to be processed by a computer.

Explanation:

5 0
3 years ago
Please you will get branlest for all cerect and awser first
FromTheMoon [43]

Answer:

b

Explanation:

I believe that is correct

6 0
3 years ago
Read 2 more answers
Monica needs to represent the month of July, with dates and days, on one of the slides in her school presentation. Which element
swat32
Time and date elements
8 0
3 years ago
Read 2 more answers
What is the HTML code symbol to the !nstagram Facts Part 2?<br><br>FIRST ONE GETS BRAINEST!!
vredina [299]

¶^↑↓→← html code symbol

5 0
3 years ago
Other questions:
  • Your bank offers to lend you $114,400 at an 8.5% annual interest rate to start your new business. The terms require you to amort
    11·1 answer
  • 38. Which of the following best describes why e-mail spoofing is easily executed? a. SMTP lacks an adequate authentication mecha
    15·1 answer
  • . Why should we favor programming to interfaces over implementations?
    6·1 answer
  • If you owned an online clothing company and you only had the resources to run one social media campaign, which platform would yo
    14·1 answer
  • A user who has special security and access to a system, such as the right to assign passwords, is called a ____.​ a. ​ technical
    8·1 answer
  • ROM is a volatile memory. true or false​
    11·1 answer
  • 3
    9·2 answers
  • Hoda needs to create a chart that is associated with an Excel spreadsheet. She needs to ensure that if the data in the spreadshe
    12·1 answer
  • What do you think about the future of Moore’s Law? Will it continue to hold true? Will other technologies help us keep on track?
    14·1 answer
  • Type of operating system used i handleheld device
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!