Computers and Technology, 01.02.2021 04:50 kayleebueno
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
Answers: 1
Computers and Technology, 22.06.2019 16:30
Primary tech skills are skills that are necessary for success in online education
Answers: 3
Computers and Technology, 22.06.2019 19:30
When creating a presentation in libre office impress, where does the editing of slides take place? a. the slides panel b. the center panel c. the tasks panel, under the masters pages tab d. the tasks panel, under the layouts tab
Answers: 1
Computers and Technology, 24.06.2019 09:50
Self contained sequences of actions to be performed are? a. expressions b. algorithms c. functions d. formulas
Answers: 1
Computers and Technology, 24.06.2019 13:00
Think of a spreadsheet as a giant calculator spread of paper chart data collector
Answers: 2
Write a program that rolls two dice until the user gets snake eyes. You should use a loop and a half...
Mathematics, 05.11.2019 05:31
Mathematics, 05.11.2019 05:31
Mathematics, 05.11.2019 05:31
English, 05.11.2019 05:31
Mathematics, 05.11.2019 05:31
Mathematics, 05.11.2019 05:31
Chemistry, 05.11.2019 05:31
Mathematics, 05.11.2019 05:31
Mathematics, 05.11.2019 05:31