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.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

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.
Transcribed Image Text: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.
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.
Transcribed Image Text: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.
Expert Solution
Step 1

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()

 

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY