Objective: To design an algorithm and implement a solution using Python programming. To write testcases and test program for correctness. Problem description A palindrome is a sequence of characters that reads the same backward and forward eg: aha is a palindrome. This wikipedia e page contains some application where identifying palindromes are useful. Your goal is to implement a single -player Palindrome game in Python. It involves a player entering several strings and gaining points based on whether the concatenated string is a palindrome or not. The game runs for a certain number of rounds specified by the player. At the end of each round, the player score is updated and displayed. You need to develop a solution in a step-by step manner and also design test cases to test your program for many scenarios based on your understanding of the requirements. Single-player Palindrome game 1) Display a prompt to the player to enter the number of rounds the player has to play the palindrome game 2) While there are remaining rounds for the user: • Play one round of the palindrome game • Calculate number of points added or deducted in this rounds of game • Add the score from this round of game to total game score • Output cumulative score from previous round and current round to the player 3) Output "Game Over" 2.1) Play one round of the palindrome game: 2.1.1) Prompt player to enter a number between 1 and 10. This is the number of strings that the player is prompted to enter. This number can be an odd or even number. 2.1.2) While there are strings to enter for the user: • Prompt player to enter a string • Concatenate the string to the previously entered string 2.1.3) Calculate the score from this round as follows:- o If the player entered an even number and the string is not a palindrome, then player gets 2 points. • If the player entered an odd number and the string is a palindrome, then player gets 5 points. o If the player entered an odd number and the string is not a palindrome, then player loses 1 point. o If none of the above conditions are met, the player neither gains nor loses any points Jinu Kabala

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

In Python 3!

Palindrome game in python. See the problem in the images attacted :)

Objective: To design an algorithm and implement a solution using Python programming. To write testcases and
test program for correctness.
O Problem description
A palindrome is a sequence of characters that reads the same backward and forward eg: aha is a palindrome. This
wikipedia e page contains some application where identifying palindromes are useful. Your goal is to implement a
single -player Palindrome game in Python. It involves a player entering several strings and gaining points based on
whether the concatenated string is a palindrome or not. The game runs for a certain number of rounds specified by
the player. At the end of each round, the player score is updated and displayed. You need to develop a solution in a
step-by step manner and also design test cases to test your program for many scenarios based on your
understanding of the requirements.
Single-player Palindrome game
1) Display a prompt to the player to enter the number of rounds the player has to play the palindrome game
2) While there are remaining rounds for the user:
• Play one round of the palindrome game
• Calculate number of points added or deducted in this rounds of game
• Add the score from this round of game to total game score
• Output cumulative score from previous round and current round to the player
3) Output "Game Over"
2.1) Play one round of the palindrome game:
2.1.1) Prompt player to enter a number between 1 and 10. This is the number of strings that the player is prompted
to enter. This number can be an odd or even number.
2.1.2) While there are strings to enter for the user:
• Prompt player to enter a string
• Concatenate the string to the previously entered string
2.1.3) Calculate the score from this round as follows:-
• If the player entered an even number and the string is not a palindrome, then player gets 2 points.
• If the player entered an odd number and the string is a palindrome, then player gets 5 points.
• If the player entered an odd number and the string is not a palindrome, then player loses 1 point.
o If none of the above conditions are met, the player neither gains nor loses any points
© Jinu Kabala
Transcribed Image Text:Objective: To design an algorithm and implement a solution using Python programming. To write testcases and test program for correctness. O Problem description A palindrome is a sequence of characters that reads the same backward and forward eg: aha is a palindrome. This wikipedia e page contains some application where identifying palindromes are useful. Your goal is to implement a single -player Palindrome game in Python. It involves a player entering several strings and gaining points based on whether the concatenated string is a palindrome or not. The game runs for a certain number of rounds specified by the player. At the end of each round, the player score is updated and displayed. You need to develop a solution in a step-by step manner and also design test cases to test your program for many scenarios based on your understanding of the requirements. Single-player Palindrome game 1) Display a prompt to the player to enter the number of rounds the player has to play the palindrome game 2) While there are remaining rounds for the user: • Play one round of the palindrome game • Calculate number of points added or deducted in this rounds of game • Add the score from this round of game to total game score • Output cumulative score from previous round and current round to the player 3) Output "Game Over" 2.1) Play one round of the palindrome game: 2.1.1) Prompt player to enter a number between 1 and 10. This is the number of strings that the player is prompted to enter. This number can be an odd or even number. 2.1.2) While there are strings to enter for the user: • Prompt player to enter a string • Concatenate the string to the previously entered string 2.1.3) Calculate the score from this round as follows:- • If the player entered an even number and the string is not a palindrome, then player gets 2 points. • If the player entered an odd number and the string is a palindrome, then player gets 5 points. • If the player entered an odd number and the string is not a palindrome, then player loses 1 point. o If none of the above conditions are met, the player neither gains nor loses any points © Jinu Kabala
O Sample test cases
You have to come up with your own test-cases, do not use the ones below. Ako, your test cases must not avertap
(they must test different aspects of your program or req.irement. These are meant to be sample test cases only.
Example 1
The player is prompted for entering number of rounds.
any ronas af palinarone gane ule you lihe to play
The player enterod 3. Now the fierst round starts and player is prompted to enter the number of strings
kter ruer af strings to cancatwute (aetu s and e):
The player chooses to input 5 strings So 5 prompts are displayed to the user and user enters S strings as follows.
civic
tivic
civie
Now it we concatenate these 5 strings we get clvictivicviccivicdel which is not a palindrome. 5kan odd number.
So based on the game nules a player gains 1 points. So total score is 1 for the player. The the output is as follows
sred pns
Now the second round starts and player is prompted to cnter the number of strings
***une *
ter ruer af stringe ta cancateate (etun i ana 1): 2
Now the player entered 2 which is even number and the concantenated string civivcivic which is not a palindrome.
So acconding to the game nules, the player gains 2 points. So the total score is -1+2-1 point. Hence, the output is
scored 1 pta
Now the thind round starts and player is prompted to enter the number of strings.
***ne
ter ruer af stringe ta cancateate (etun i ana 1):A
civic
civic
civic
Now the player entered 3 which is an odd number and the concantenated string civicciviccivic isa palindrome. So
according to the game nules, the player gains 5 paints. So the total score is -1+2+5-6 point. Also the game is over
since the player has played all three rounds. Hence, the output is
a scored te
ae avert
Example 2
Hore the player wants to play 4 rounds of the game. But, when adked to enter number of strings in round 2, the
player enters a number 11 which is outside the range 1-10 Hence, the game ends as shown in this cxample
ary ronas af palinaron gan ule you Like to play e
kter ruer af strings ta cancatwute (aetu s and e):
civic
tivic
civic
civic
dell
oreds pts
ter rer af stringe ta cancatawate (etu ana 18): 11
ae avert
Constraints & Assumptions
. fa number outside the range of number of strings input 1-10 the game ends and output "Game over is
displayed
• The inputs are case insensitive. So Civic is same as 'civic' and considered a palindrome
Transcribed Image Text:O Sample test cases You have to come up with your own test-cases, do not use the ones below. Ako, your test cases must not avertap (they must test different aspects of your program or req.irement. These are meant to be sample test cases only. Example 1 The player is prompted for entering number of rounds. any ronas af palinarone gane ule you lihe to play The player enterod 3. Now the fierst round starts and player is prompted to enter the number of strings kter ruer af strings to cancatwute (aetu s and e): The player chooses to input 5 strings So 5 prompts are displayed to the user and user enters S strings as follows. civic tivic civie Now it we concatenate these 5 strings we get clvictivicviccivicdel which is not a palindrome. 5kan odd number. So based on the game nules a player gains 1 points. So total score is 1 for the player. The the output is as follows sred pns Now the second round starts and player is prompted to cnter the number of strings ***une * ter ruer af stringe ta cancateate (etun i ana 1): 2 Now the player entered 2 which is even number and the concantenated string civivcivic which is not a palindrome. So acconding to the game nules, the player gains 2 points. So the total score is -1+2-1 point. Hence, the output is scored 1 pta Now the thind round starts and player is prompted to enter the number of strings. ***ne ter ruer af stringe ta cancateate (etun i ana 1):A civic civic civic Now the player entered 3 which is an odd number and the concantenated string civicciviccivic isa palindrome. So according to the game nules, the player gains 5 paints. So the total score is -1+2+5-6 point. Also the game is over since the player has played all three rounds. Hence, the output is a scored te ae avert Example 2 Hore the player wants to play 4 rounds of the game. But, when adked to enter number of strings in round 2, the player enters a number 11 which is outside the range 1-10 Hence, the game ends as shown in this cxample ary ronas af palinaron gan ule you Like to play e kter ruer af strings ta cancatwute (aetu s and e): civic tivic civic civic dell oreds pts ter rer af stringe ta cancatawate (etu ana 18): 11 ae avert Constraints & Assumptions . fa number outside the range of number of strings input 1-10 the game ends and output "Game over is displayed • The inputs are case insensitive. So Civic is same as 'civic' and considered a palindrome
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Declaring and Defining the Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education