Function task3() is a simple dice game that roles a dice ten times. The user wins if they have more than 35 points. The number of points is the sum of all the dice rolls and a bonus of 10 points if exactly two of the dice rolls are ones. Implement your dice game as follows: (1) Print a welcome message (2) Output the result of 10 dice rolls using randint(1,6)–print roll # and dice value as shown below. (3) Sum up the values of rolls 1-10. (4) If two of the rolls were the number 1, then print out "+10 Bonus for snake eyes [1][1]!". Add 10 points to the sum-[Note that more than two "ones" do not get a bonus]. (5) If the final points (including bonus) is greater than 35, the user wins; otherwise, they lose. Print out the appropriate message as shown below. (6) Ask the user to input 'Y' to play again. (7) If the user inputs either 'Y' or 'y', return to (1) and play the game again. Otherwise, the function is done.
Python code. It is just one question.
Need to use Variables and expression, strings, conditional-statements, loops.
Thank you. Ill also put example.
![Function task3() is a simple dice game that roles a dice ten times. The user wins if they have more than 35
points. The number of points is the sum of all the dice rolls and a bonus of 10 points if exactly two of the dice
rolls are ones.
Implement your dice game as follows:
(1) Print a welcome message
(2) Output the result of 10 dice rolls using randint(1,6)-print roll # and dice value as shown below.
(3) Sum up the values of rolls 1-10.
(4) If two of the rolls were the number 1, then print out "+10 Bonus for snake eyes (1][1]!".
Add 10 points to the sum-[Note that more than two "ones" do not get a bonus].
(5) If the final points (including bonus) is greater than 35, the user wins; otherwise, they lose. Print out the
appropriate message as shown below.
(6) Ask the user to input 'Y' to play again.
(7) If the user inputs either 'Y' or 'y', return to (1) and play the game again. Otherwise, the function is done.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fdb149631-7aca-418e-8f94-0d5f70bfeb88%2F874f6a41-f691-4489-894a-93eba2ea3bee%2Ffflr6nh_processed.png&w=3840&q=75)
![Dice Game
Rolling Die 10 times
Roll 1: [6] +
Roll 2: [2]
Roll 3: [6]
Roll 4: [6]
Roll 5: [5]
Roll 6: [1]
Roll 7: [1]
Roll 8: [1]
Roll 9: [3]
Roll 10: [6]
Total 37 -- OVER 35 POINTS [YOU WIN!].
Enter 'Y' to play again: y
Print the dice values as shown. Print roll #
(starting from 1) and the dice value in (].
More than two [1] does not result in the
"snake eye" bonus of 10 points.
After showing the two rolls results, sum up
the value of all the dice. If it is more than 35
the user wins
Ask the user to enter 'Y' to play again.
Dice Game
if Y' or y'is entered, continue to play.
Rolling Die 10 times
Roll 1: [6]
Roll 2: [1]
Roll 3: [4]
Roll 4: [5]
Roll 5: [2]
Roll 6: [1]
Roll 7: [4]
Roll 8: [3]
Roll 9: [1]
Roll 10: [2]
Total 29 -- TOO FEW POINTSS [YOU LOSE!]-
Enter 'Y' to play again: y
Here the sum for the second game is 35 or
less. The user loses.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fdb149631-7aca-418e-8f94-0d5f70bfeb88%2F874f6a41-f691-4489-894a-93eba2ea3bee%2F6s6t5pk_processed.png&w=3840&q=75)

import random
def Task3():
total = 0
while True:
print("Dice Game")
print("Rolling Dice 10 times")
countOnes = 0
for i in range(1,11):
num = random.randint(1,6)
total = total + num
if num == 1:
countOnes = countOnes + 1
print("Roll ", i, ": [", num, "]")
if countOnes == 2:
total = total + 10
if total > 35:
print("Total ", total, " -- OVER 35 POINTS [YOU WIN!]")
else:
print("Total ", total, " -- TOO FEW POINTS [YOU LOSE!]")
ch = input("Enter 'Y' to play again: ")
if ch == 'Y':
continue
else:
break
#Calling function
Task3()
Step by step
Solved in 2 steps with 2 images









