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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!