Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

bartleby

Concept explainers

Question
100%

consider a program that reads data from a text file called: "klingon-english.txt" (shown below). How would one construct such a program with the following conditions:

1. Ask the user to choose a Klingon consonant they want to practice with. Ask again if the user’s answer is not a valid Klingon consonant, until the user enters a valid consonant.

2. Find a Klingon word that starts with the chosen consonant (the text file contains only one word that starts with any given consonant, so you don’t need to use the random library)

3. Ask the user to translate the chosen word into Klingon

4. Print "Correct" if the user’s answer is correct

5. Print "Sorry, you’re wrong!" if the user’s answer is wrong

6. Print The correct answer is ... if all three user’s answers are wrong

You will also factor in this version:

7. If the answer is incorrect, show the first hint: the first and last characters of the correct Klingon word. When showing a hint, replace all other characters with a star (*)

8. If the answer is still incorrect, show the second hint: the first and the last characters plus an extra random character of the correct Klingon word.

You must read data from the provided text file, that is absolutely essential in this lab assignment. You can not hardcode the words:

Here is the text file:

batlh|honor
cha'pujqut|dilithium crystal
De'wI'|computer
ghIgh|necklace
HablI'|data transceiving device
jabbI'ID|data transmission
laSvargh|factory
mIgh|be evil
noch|sensor
pong|name
qawHaq|memory banks
Qagh|error, mistake
rIgh|be lame
Sagh|be serious
tayqeq|civilization
voDleH|emperor
wa'leS|tomorrow
yuQHom|planetoid
'avwI'|guard

The attached pictures are example Demonstrations of how a code like this might work.

How would I start to code a program like this and which functions should I use?

Thank you very much!

> V
How do you translate emperor to Klingon? You have 3 attempts left.
> vagh
Sorry, you're wrong!
How do you translate emperor to Klingon? You have 2 attempts left.
Hint: v****H
> vaaaaH
Sorry, you're wrong!
How do you translate emperor to Klingon? You have 1 attempts left.
Hint: vo***H
> vooooH
Sorry, you're wrong!
The correct answer is voDleH.
$ exit
expand button
Transcribed Image Text:> V How do you translate emperor to Klingon? You have 3 attempts left. > vagh Sorry, you're wrong! How do you translate emperor to Klingon? You have 2 attempts left. Hint: v****H > vaaaaH Sorry, you're wrong! How do you translate emperor to Klingon? You have 1 attempts left. Hint: vo***H > vooooH Sorry, you're wrong! The correct answer is voDleH. $ exit
$ python klingon-quiz4.py
Which consonant do you want to practice with?
> a
Please enter a valid Klingon consonant.
> U
Please enter a valid Klingon consonant.
> 0
Please enter a valid Klingon consonant.
> X
Please enter a valid Klingon consonant.
> m
How do you translate be evil to Klingon? You have 3 attempts left.
expand button
Transcribed Image Text:$ python klingon-quiz4.py Which consonant do you want to practice with? > a Please enter a valid Klingon consonant. > U Please enter a valid Klingon consonant. > 0 Please enter a valid Klingon consonant. > X Please enter a valid Klingon consonant. > m How do you translate be evil to Klingon? You have 3 attempts left.
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Computer Science
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
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education