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
ASAP PLZ!!!!!! Type the correct answer in the box. Spell all words correctly What are the steps of moving data into a data wareh
babunello [35]

Answer:

At its most basic, the ETL process encompasses data extraction, transformation, and loading. While the abbreviation implies a neat, three-step process – extract, transform, load – this simple definition doesn't capture: The transportation of data.

Explanation:

hope this work man

4 0
3 years ago
An app builder has created a report for sales people to view records from the custom object, some users have complained that the
a_sh-v [17]

Answer:

Check sharing rules

Check organization-wide defaults

Check the user s profile for object settings

Explanation:

There is a need for some people to see the total transparency of the records that are meant to be shared with a select group of people. There are certain things that can be done for this. The first one is that the sharing rules should be checked. To whom are the details shared with. The next one is the filters that are used.

These can be reported and changed accordingly. Lastly, the whole organization’s defaults can be checked. This is something that can be done when the previous methods that were done did not work that well. Once some changes are done, the people can check if they already work and if the records can be viewed.

6 0
4 years ago
236. A system such as a printer, smart TV, or HVAC controller, typically uses an operating system on what is called a:
irakobra [83]

Answer:

Embedded System

5 0
2 years ago
Read 2 more answers
A) Explain the concept of memory management unit as related to Operating systems.
USPshnik [31]

Answer:

Memory is the faculty of the brain by which data or information is encoded, stored, and retrieved when needed. It is the retention of information over time for the purpose of influencing future action.

Explanation:

4 0
3 years ago
What does an arrow next to a menu item indicate?
katrin2010 [14]
Can you provide a screenshot maybe?
There are many menu items.

4 0
3 years ago
Other questions:
  • An effective password can help prevent
    11·2 answers
  • Question 2: Sum of consecutive odd View Past Answers No past answers. Write a program which asks user to enter an integer n, cal
    8·2 answers
  • I am doing Microsoft Excel and I have do formulas, Can some please explain to me how do them?
    14·1 answer
  • Which design approach help build sites that optimize varied screen sizes
    5·1 answer
  • Is it better to meet online or offline<br> (Please answer QUICK)<br><br> Thanks :')
    5·2 answers
  • _____ check to see what links are on the user's web page and make sure they work; if a link is broken, they identify it and incl
    8·2 answers
  • What to do when you accidentally delete usb drivers?
    8·1 answer
  • What structure is a candle​
    13·1 answer
  • Go to this link: https://platform.breakoutedu.com/game/play/going-buggy-78#
    8·1 answer
  • What does the x mean in .docx
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!