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]
2 years ago
15

CS160 Computer Science I In class Lab 10

Computers and Technology
1 answer:
lianna [129]2 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
Professionals within the creative imaging fields must have which of the following items to showcase technical expertise?
Y_Kistochka [10]

Answer:

Portfolio

Explanation:

6 0
3 years ago
Read 2 more answers
Word can only print documents on one size of paper.<br><br> True or false
Elena L [17]

Answer:

False

Explanation:

You can always go in the document settings to change the layout and make the paper wider (landscape).

Layout > Orientation

Choose portrait or landscape

5 0
2 years ago
What is episodic memory? knowledge about words, concepts, and language-based knowledge and facts information about events we hav
tankabanditka [31]

Answer:

<em>information about events we have personally experienced</em>

Explanation:

Episodic memory is <em>the actual memory of a particular event that a person has, so it will be different from the recall of the same encounter or experience by someone else.</em>

Often, episodic memory is mistaken with autobiographical memory, and while autobiographical memory includes episodic memory, it also depends on semantic memory.

<em>For instance, you might know the city you were born in and the date, though you have no particular birth memories.</em>

3 0
3 years ago
An operating system coordinations the___ of a computers operation
qwelly [4]
\\\\\\\\\\\\\\\\\\\\\\\\\Operating system///////////////////////
                            Is the Answer
8 0
3 years ago
The area of a square is stored in a double variable named area. Write an expression whose value is length of the diagonal of the
melisa1 [442]

Answer:

sqrt(area)

Explanation:

  • Here sqrt is a short form of square root.
  • area is a variable name having he area of square.
  • When the function is called, it will give the square root of the value stored in variable area.

As we have to find the length of the diagonal, we must knew that as all sides of the square are same in length so are the diagonals. This means that each of the four sides of the square and it diagonals are equal in length.

So a square has: length=breadth=diagonal

As  Area= length*breadth

√area = length           (as length = diagonal length)

So     √area = diagonal length

4 0
3 years ago
Other questions:
  • Adding a ____ to text adds depth and helps the letters display prominently.
    5·1 answer
  • True / False
    5·1 answer
  • Declare a prototype for a function called isPrime that returns true or false and expects a single parameter named number of type
    14·1 answer
  • 2
    11·1 answer
  • Which option in Outlook allows a user to look at multiple calendars in a side-by-side fashion?
    14·2 answers
  • All of the following are advantages of database-stored information, except ______________. Multiple Choice
    7·1 answer
  • 8.13 LAB: Elements in a range Write a program that first gets a list of integers from input. That list is followed by two more i
    8·1 answer
  • Which of the following does not use a Graphic User Interface?
    14·1 answer
  • A company is developing a smart TV that connects to a wireless home network. Which technology can best help to establish this co
    11·2 answers
  • Which of these is NOT an input device?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!