Computers and Technology

CS160 Computer Science I In class Lab 10 Objective:
Work with dictionaries
Work with strings
Work with files
Assignment:
This program will read a file of English words and their Spanish translation. It then asks the user for an English word. If it exists in your dictionary the Spanish translation is displayed. If the English word does not exist in the dictionary the program states that the word does not exist in its list of words.
Specifics:
Create a text file, with one English word and a Spanish word per line, separated by a colon. You can create the language file using a text editor, you do not need to write a program to create this file. An example of the file might be:
one:uno
two:dos
three:tres
four:cuatro
five:cinco
six:seis
seven:siete
eight:ocho
nine:nueve
ten:diez
After reading the text file, using it to fill up a dictionary, ask the user for an English word. If the word exists, print out the Spanish version. If the word does not exist state that the word is not in your list. Continue this process of asking for a word until the user does not enter a word (just pressed Enter).
As you might have noticed, there is nothing in the program that limits this Spanish words. This program can be written to work with any translation, so feel free to make it be French, or German or any other language where you can come up with a list of translated words. You also are not limited to 10 words, that is just the list I came up with for the example. The number of key/values pairs that you have in your dictionary is basically limited by the memory in your computer.
Hints
You will need to determine if the key (the English word) exists in the dictionary. Use the in operator with the dictionary, or the get() method. Either can be used to avoid crashing the program, which happens if you attempt to use a key that does not exist.
An example of running the program might be:
Enter the translation file name: oneToTen. txt
> Enter an English word to receive the Spanish translation.
Press ENTER to quit.
Enter an English word: one
he Spanish translation is uno
Enter an English word: ten
The Spanish word is diez
Enter an English word: 5
I don’t have that word in my list.
Enter an English word: three
The Spanish word is tres

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 23:30, skywil8981
Step 1: choose your topics review the project milestone reflections you submitted for modules 1 through 4. choose the one major idea or concept from each module that you feel most applies to your life. in addition, choose an important concept from module 5 that applies to your life. step 2: write your guidebook for each module: write a catchy headline that clearly and concisely sums up your chosen idea or concept write a brief explanation that includes a description of the concept, why it is important, and how it can be applied to your life to make a positive impact choose an exciting, powerful, or engaging image that illustrates your concept remember, you are writing one for each module, so you will have a total of five headlines, five descriptions, and five images. step 3: design your guidebook choose a format to present your digital guidebook. there are many 21st century tools available for creating and submitting your work in the online environment. for more information on tools your school uses, contact your instructor or visit the web 2.0 tools area.
Answers: 3
image
Computers and Technology, 23.06.2019 10:00, austintules2005
Whats three fourths of 15(this is supposed to be in math but i clicked too fast)
Answers: 1
image
Computers and Technology, 24.06.2019 08:00, Maxxboogie
Can someone work out the answer as it comes up in one of my computer science exams and i don't understand the cryptovariables
Answers: 1
image
Computers and Technology, 24.06.2019 13:30, andybiersack154
Consider jasper’s balance sheet. which shows how to calculate jasper’s net worth?
Answers: 1
Do you know the correct answer?
CS160 Computer Science I In class Lab 10 Objective:
Work with dictionaries
Work with s...

Questions in other subjects:

Konu
Arts, 05.05.2020 07:17
Konu
Mathematics, 05.05.2020 07:17