Question
Write a program in Python using Boolean operators (and, or, not, >=, etc. ) and while loop that keeps track of a game score and
Write a program in Python using Boolean operators (and, or, not, >=, etc. ) and while loop that keeps track of a game score and declares the winner when the game is over. A game is over when either one player scores 10 or more points with at least 2 more points than the opponent. A game is also over when one player scores 7 points and the opponent scores none. The program should begin by asking the names of the two players. Then it should keep asking who won the point till the game is over. In the end it should print the winner and the final score. Following is a sample trace of the desired program, things in bold should be printed through the program.
>>> import game >>> game.main()
Give name of the first player: John
Give name of the second player: Mary
Current score: John : 0 Mary : 0
Who won the point? John or Mary: John
Current score: John : 1 Mary : 0
Who won the point? John or Mary: John
Current score: John : 2 Mary : 0
Who won the point? John or Mary: John
Current score: John : 3 Mary : 0
Who won the point? John or Mary: John
Current score: John : 4 Mary : 0
Who won the point? John or Mary: John
Current score: John : 5 Mary : 0
Who won the point? John or Mary: John
Current score: John : 6 Mary : 0
Who won the point? John or Mary: John
John is the winner!
Final score: John : 7 Mary : 0
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started