pic fot the
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
Related questions
Question
I have attched a pic fot the qustion
![Problem definitions
We want to write a Python program for n players, which are pluying a tumament. In this competition
players lve 5 simple arithmetic problems. The arithmetic peoblems consist of simple addition
uperations of the form
umberl + number2 -.
where the operands wmberi and number2 are randomly generated.
Initially your program displays a menu to enter the umber of players and the difficulty level as shown
in figure
Tournanent, guia
Enter nunber of players
Player 1
Level
-E or e for Easy
-A ora for Aevancet level
level
Enter your cheicei
Incorrect irout try apain
Levets
-E or e for tesy
-A or a for Aevancet level
level
Enter yur cheice it
Figure 1 Program initial memu
The difficulty level determines the number of digits in the operands mumberl and number2:
• Eany level means the operands consists of a umique digit (0, 1, 29)
• Advanced level means the operands comists of two digits (10, 11 99)
Use the randum number generator to determine mmherl and nunheer2 Afber the plaver
chonses the difficulty level, your program displays the 5 problems. For instance, the sample
below could be given in case where the player chooses advanced level:
40 + 90
34. 88
23. 65 -
14+ 38
53 + 65 =
The player has a muximum of two tries for cach question. If the player fint anwer's in comect, the
next problem is presented, otherwise shehe is given a second try. Each conect amwer is worth 1
mark. At the end of the quiz, the program displays for cach player,
• The number of eorrect answers,
• The number of tries, and
• The score.
The seure is calculated by dividing the number of correct answers by mumber of tries. The program
then prints a report of the results to an output file The report has a tahbular format, where each ow is
the recmd of each player (Figure 2). The table ennsists of the following four column
• Player's nunher.
• Number of eorrect awnaers
• Numler af trier, and
• Score
The output file name consists of your name and your ID, eg. Ahned 14532. txt
playr nue
Tournanent Quiz
na.corr ans
ne_tries
score
e.57
e.67
Figure 2 Sample output file
Tasks: Your program should cunsist of the following functions
Main: A function that performs file processing, reads mumber of participants, calls other functions
nd penerates the output file.
showtenu: A fimction with no parameters and retums a char that represents the level of difficulty.
findoperands: A function with me input parameter: the difficulty level. It returns a tuple of two
randomly generated operands.
userQuiz A function to process a single player. This function has the difficulty as a umique
parameter. It returna a tuple of the following frmat:
mumb_of corr_wens, numb_of trien, seore
2](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F16392586-1330-4a33-bf06-6a32244530d8%2F186f5e37-0616-41c6-b2d1-f00eff942c33%2Fnqirhpdi_processed.jpeg&w=3840&q=75)
Transcribed Image Text:Problem definitions
We want to write a Python program for n players, which are pluying a tumament. In this competition
players lve 5 simple arithmetic problems. The arithmetic peoblems consist of simple addition
uperations of the form
umberl + number2 -.
where the operands wmberi and number2 are randomly generated.
Initially your program displays a menu to enter the umber of players and the difficulty level as shown
in figure
Tournanent, guia
Enter nunber of players
Player 1
Level
-E or e for Easy
-A ora for Aevancet level
level
Enter your cheicei
Incorrect irout try apain
Levets
-E or e for tesy
-A or a for Aevancet level
level
Enter yur cheice it
Figure 1 Program initial memu
The difficulty level determines the number of digits in the operands mumberl and number2:
• Eany level means the operands consists of a umique digit (0, 1, 29)
• Advanced level means the operands comists of two digits (10, 11 99)
Use the randum number generator to determine mmherl and nunheer2 Afber the plaver
chonses the difficulty level, your program displays the 5 problems. For instance, the sample
below could be given in case where the player chooses advanced level:
40 + 90
34. 88
23. 65 -
14+ 38
53 + 65 =
The player has a muximum of two tries for cach question. If the player fint anwer's in comect, the
next problem is presented, otherwise shehe is given a second try. Each conect amwer is worth 1
mark. At the end of the quiz, the program displays for cach player,
• The number of eorrect answers,
• The number of tries, and
• The score.
The seure is calculated by dividing the number of correct answers by mumber of tries. The program
then prints a report of the results to an output file The report has a tahbular format, where each ow is
the recmd of each player (Figure 2). The table ennsists of the following four column
• Player's nunher.
• Number of eorrect awnaers
• Numler af trier, and
• Score
The output file name consists of your name and your ID, eg. Ahned 14532. txt
playr nue
Tournanent Quiz
na.corr ans
ne_tries
score
e.57
e.67
Figure 2 Sample output file
Tasks: Your program should cunsist of the following functions
Main: A function that performs file processing, reads mumber of participants, calls other functions
nd penerates the output file.
showtenu: A fimction with no parameters and retums a char that represents the level of difficulty.
findoperands: A function with me input parameter: the difficulty level. It returns a tuple of two
randomly generated operands.
userQuiz A function to process a single player. This function has the difficulty as a umique
parameter. It returna a tuple of the following frmat:
mumb_of corr_wens, numb_of trien, seore
2
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Knowledge Booster
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.Recommended textbooks for you
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
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)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
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)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education