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
VikaD [51]
3 years ago
6

In this exercise, your function will receive 2 parameters, the name of a text file, and a list of strings. The function will wri

te one line to the text file. The line will contain the fourth character of every string in the list. For any strings that don't have four characters, use x. Be sure to include the newline character at the end.
Computers and Technology
1 answer:
diamong [38]3 years ago
5 0

Answer:

# the function is defined

# it takes 2 arguments: filename and list of string

def solution(filename, listOfString):

   # the file is opened in write mode

   # so that we can write to it

   with open(filename, 'w') as file_object:

       # we loop through the entire list of string

       # this looping help us know what to write to the file

       for each_string in listOfString:

           # if the length of the string is less than 4

           # we write 'x' with a new line

           if len(each_string) < 4:

               file_object.write("x\n")

           # else if the length of the string is greater than equals 4

           # we write the fourth character

           # and also add new line

           else:

               file_object.write(each_string[3])

               file_object.write("\n")

Explanation:

The function is written in Python. It takes two argument; filename and list of string.

It opens the file in write mode and then loop through the list of string. During the loop, we know what to write to the file.

In the length of a string is less than 4; we write 'x' else we write the fourth character in the string. The fourth character has an index of 3 because string uses zero index counting like a string. Starting from zero; 0, 1, 2, 3, 4... the fourth character has an index of 3.

You might be interested in
Nancy would like to configure an automatic response for all emails received while she is out of the office tomorrow, during busi
Stella [2.4K]

she can appoints someone she trust to act on her behalf

4 0
3 years ago
Read 2 more answers
Consider an environment in which there is a one-to-one mapping between user-level threads and kernel-level threads that allows o
DENIUS [597]

Explanation:

According to the situation mentioned in the question about the model that can make the multi threaded execution faster as compared with the single threaded counterparts programs because multi-threaded programs have the capability to execute simultaneously in multiple processes.

In this type of system ,the blocking system cannot block the complete execution because kernel thread is present for every user thread .So, if one kernel thread gets blocked , others will still keep running .

Whereas, for uni-processor system , the program has to wait for the input -output operation completion for most of the time.Thus, multi-threaded program can execute faster than uni-processor.

 

5 0
3 years ago
Victoria enjoys laughing with her friends as they walk around the track after school. Which best describes her hate rate during
Pachacha [2.7K]
Her heart rate would be 56 or 75 it high but not that high because shes walking
3 0
3 years ago
The ability to memorize well is an example of
Soloha48 [4]

personal trait because it something that just comes to mind

3 0
3 years ago
Read 2 more answers
While accessing mail through the mail command interface, a user sees 5 new messages in his mailbox. Since the second message app
RUDIKE [14]

Answer:

The answer is "print 2".

Explanation:

The mail command, which is also known as the return path, bounce address, as well as mfrom, and sends the back address. This command is used to set the message receiver, order RCPT. It's also composed of the message for the header, and it is the empty line of the message body, and in this command to read the second message we use the print 2 message.

7 0
3 years ago
Other questions:
  • When using a wireless mouse, what is the most common port used for the transmitter? 
    7·1 answer
  • Instructions:Drag the tiles to the boxes to form correct pairs.
    11·2 answers
  • Which of the following about if statement is true? A. The condition is a Boolean expression B. A Boolean expression is something
    15·1 answer
  • When parallel parking, you should select a space that is __________ as long as your car.
    11·1 answer
  • Question # 6
    11·2 answers
  • While developing a network application, a programmer adds functionally that allows her to access the running program without aut
    14·1 answer
  • Select the correct answer.
    10·1 answer
  • Write a one page report describing the computer the client used, who else had access to it and other relevant findings. Referenc
    7·1 answer
  • Which of the following are the most important reasons people in the 1920s were so interested in seeing lifelike stories in audio
    6·1 answer
  • 5. An external CSS file is saved with D. Answer the following questions. 1. Explain the purpose and advantages of using CSS.​
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!