1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Wittaler [7]
3 years ago
15

CS160 Computer Science I In class Lab 10

Computers and Technology
1 answer:
lianna [129]3 years ago
5 0

Answer:

The program in Python is as follows:

fname = input("Enter the translation file name: ")

with open(fname) as file_in:

   lines = []

   for line in file_in:

       lines.append(line.rstrip('\n'))

myDict = {}

for i in range(len(lines)):

x = lines[i].split(":")

myDict[x[0].lower()] = x[1].lower()

print("Enter an English word to receive the Spanish translation.\nPress ENTER to quit.")

word = input("Enter an English word: ")

while(True):

if not word:

 break

if word.lower() in myDict:

 print("The Spanish word is ",myDict[word.lower()])

else:  

 print("I don’t have that word in my list.")

word = input("Enter an English word: ")

Explanation:

This prompts the user for file name

fname = input("Enter the translation file name: ")

This opens the file for read operation

with open(fname) as file_in:

This creates an empty list

   lines = []

This reads through the lines of the file

   for line in file_in:

This appends each line as an element of the list

       lines.append(line.rstrip('\n'))

This creates an empty dictionaty

myDict = {}

This iterates through the list

for i in range(len(lines)):

This splits each list element by :

x = lines[i].split(":")

This populates the dictionary with the list elements

myDict[x[0].lower()] = x[1].lower()

This prints an instruction on how to use the program

print("Enter an English word to receive the Spanish translation.\nPress ENTER to quit.")

This prompts the user for an English word

word = input("Enter an English word: ")

This loop is repeated until the user presses the ENTER key

while(True):

If user presses the ENTER key

if not word:

The loop is exited

 break

If otherwise, this checks if the word exists in the dictionary

if word.lower() in myDict:

If yes, this prints the Spanish translation

 print("The Spanish word is ",myDict[word.lower()])

If otherwise,

else:

Print word does not exist

 print("I don’t have that word in my list.")

Prompt the user for another word

word = input("Enter an English word: ")

You might be interested in
In a swap you need a _____________ variable so that one of the values is not lost.
Marat540 [252]

Answer:

i would love to actually answer this im so sorry

Explanation:

8 0
3 years ago
Read 2 more answers
Please give all the answer​
il63 [147K]

Answer:

am/is=was

are=were

do=did

go=went

eat=ate

have=had

make=made

take=took

see=saw

fly=flew

sell=sold

tell=told

find=found

sent=sent

Explanation:

These are all present/ past tense

I hope this helps.

5 0
3 years ago
Read 2 more answers
Some people argue that developers should not be involved in testing their own code but all testing should be the responsibility
GalinKa [24]

Answer:

People code in their own styles which can make it hard for other people to understand it, especially if it doesn't have any documentation, but that could be a reason to let a separate team test it, so the developer can learn how to code in a way that is understood by most people.

Explanation:

7 0
3 years ago
Why is Thomas Jefferson considered an accomplished man , or a Renaissance man?​
lesantik [10]
The term “Renaissance man” means for a very clever person to be good at many different things.
4 0
3 years ago
Write an algorithm
liq [111]

Answer:Pseudocode & Algorithm Example 1: Write an algorithm to determine a student's final ... Pseudocode & Algorithm Pseudocode: Input a set of 4 marks Calculate their average by ... Information system flowcharts show how data flows from source documents ... Different symbols are used to draw each type of flowchart.

Explanation:

7 0
3 years ago
Other questions:
  • You are working at establishing a computer network and communications support for incident personnel. where are you working?
    12·1 answer
  • How do rubrics increase learning?
    15·2 answers
  • Which element in Access is an ideal data source?
    12·2 answers
  • Alpha Technologies, a newly established company, wants to share information about its work with people all over the world. Which
    11·1 answer
  • 1)A popular and useful tool for strategic planning is SWOT analysis. SWOT stands for
    6·1 answer
  • Establishing responsibilities, planning to best support the organization, acquiring validity, ensuring performance, conformity w
    12·1 answer
  • If a user has one column in a table and would like to make it into two columns which command should be used?
    8·2 answers
  • The music is the soul who says this
    12·1 answer
  • Which of the following is a benefit, as well as a risk, associated with peer-to-peer networks?
    6·2 answers
  • Ill give alot of points if you answer: How do I get a 100 dollar ps4
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!