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
What are two different ways by which a laptop could utilize the cellular network connection of a mobile device
Stella [2.4K]

Answer:

Tethering and hotspot

Explanation:

Tethering and hotspot are the two different ways by which a laptop could utilize the cellular network connection of a mobile device.

Tethering usually involves connecting the computer or smartphone to the internet with the aid of a USB cable while hotspot involves connection of the device to the internet through the WIFI option.

6 0
3 years ago
“What does it mean when we “rework” copyrighted material?”
Alja [10]
We use ideas and thoughts that have already been protected by the law which is called Copyright. We reworking copyright material means we are taking somebody's ideas and calling it ours. Which is not right by the law.
3 0
3 years ago
Read 2 more answers
What formula would you enter in c4 that combines a4 and b4 to get a result like c2
Paul [167]

Available options

=A4&&B4

=A4&" "&B4

="A4"&""&"34"

=A4&""&B4

Answer:

=A4&""&B4

Explanation:

In a Microsoft Excel spreadsheet, to combine the content of two cells into another cell, a user will have to use the command &

Hence, in this case, given that there is no need to have any character or blank space in between the content of the starging cells, which is just A4 and B4, then we have the following technique

1. Select the cell C2

2. Input the command = or +, then select cell A4

3. Input the command &

4. Then select the cell B4

5. Click enter.

Therefore, the answer should appear as =A4&B4.

But from the available options, there is nothing like that, so we pick =A4&""&B4 because it gives the same outcome.

6 0
3 years ago
The matrix theory is used in the ___ technique
wlad13 [49]

Answer:

The matrix theory is used by hill cipher.

Explanation:

Th technique which uses matrix theory is hill cipher technique.

Hill cipher technique is a polygraphic substitution cipher and it is based on linear algebra.

For encrypting a message in Hill Cipher technique each block of n letters is multiplied by an invertible matrix of nxn and that to against modulus 26 and  for the decryption of the message, every block is multiplied by the inverse of the matrix that was used for encryption.

3 0
3 years ago
CS provides a standardized approach to the command, control, and coordination of _______ emergency personnel.
bekas [8.4K]

Answer:On-scene emergency

Explanation: ICS(Incident Command System) is the the safety system which works on certain command in the time of emergency. It functions on the steps like controlling the on-scene emergency and coordinating it with the help of command and efficient resources.

This system provides the benefit of maintaining the security and safety of the on-scene individuals like workers, students etc.

8 0
3 years ago
Other questions:
  • Directions Use your imagination and a word processor to write a business letter with two to three paragraphs. Your business lett
    5·1 answer
  • What is the opportunity cost of computers when moving from point A to point B? -15 DVDs b. What is the opportunity cost of compu
    13·1 answer
  • What steps should Jeremy take to get himself motivated to study for the test?
    12·2 answers
  • What command launches the remote desktop client for windows?
    12·1 answer
  • Assume the availability of a function is_prime. Assume a variable n has been associated with positive integer. Write the stateme
    15·1 answer
  • A computer technician is responding to a call about a printer that is causing streaks to appear on every printout. Which of the
    5·1 answer
  • Write Tic tac toe program in python for beginners pls
    10·1 answer
  • A ___________ variable is used to add up a set of values. fill in the blank
    8·1 answer
  • For a business that is properly using a social media information system, the system can
    13·1 answer
  • Leslie’s parents put a big dry-erase board on the refrigerator and let the kids write suggestions for how to organize and assign
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!