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
Media applications that play audio or video files are part of a class of workkloads called "streaming" workloads (i.e., they bri
emmasim [6.3K]

Answer:

Following is the detailed answer as needed.

<h3>I hope it will help you!</h3>

Explanation:

8 0
2 years ago
A computer on a network that is not the server​
katrin [286]

Answer:

A peer-to-peer network is one in which two or more PCs share files and access to devices such as printers without requiring a separate server computer or server software. ... A P2P network can be an ad hoc connection—a couple of computers connected via a Universal Serial Bus to transfer files.

5 0
2 years ago
After this week im gonna be moderator who ever needs help let me know
Sav [38]

Answer:

ok

Explanation:

thanks, for offering help through here. Have a nice day.

4 0
3 years ago
A small company with 100 computers has hired you to install a local area network. All fo the users perform functions like email,
Nadusha1986 [10]

Answer:

Based on the requirements indicated in the question above, the best Local Area Network (LAN) operating system that can be used is

Windows 7 , 8.1 or Windows 10. This is because they all are configured to handle extensive LAN activity and can connect over 200 users.

Explanation:  

Generally speaking, Windows 10 packs more improvement over the previous windows.

Cheers

6 0
2 years ago
. If you executean infinite recursive function on a computer it will executeforever.
S_A_V [24]

Answer:

b. False

Explanation:

If you execute an infinite recursive function on a computer it will NOT execute forever.

4 0
2 years ago
Other questions:
  • How will using ascending order on a field that contains dates sort a list?
    12·2 answers
  • How can you ensure that your web pages are compliant with a w3c standard?
    9·1 answer
  • Convert 578.2 into hexadecimal​
    9·1 answer
  • A browser is used for creating Web pages. true or false?
    5·2 answers
  • colby lives a very career-driven lifestyle. he works long hours and enjoys making a lot of money by working overtime. after he a
    14·2 answers
  • Can someone please please please help me!
    10·1 answer
  • Which task can a company perform with intranets
    8·1 answer
  • Describe a cellular network, its principle<br> components and how it works.
    7·1 answer
  • Is social media bringing people together or cause in sepretation?​
    11·2 answers
  • A corporation is looking to receive approval from its shareholders. The corporation needs to communicate financial information a
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!