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
What is an elliptic curve cryptosystem (ECC)?
andrezito [222]

Answer:

d. Provides a stronger cryptographic result with a shorter key.

Explanation:

The elliptic curve cryptosystem (ECC) is a public key cipher that provides higher security than other public key cryptosystems, such as the RSA, with shorter key.

So the correct answer is:

d. Provides a stronger cryptographic result with a shorter key.

3 0
3 years ago
Casual or informal group meetings are common. Here youcasually chat over tea, meet after work, or get together for purelysocial
SCORPION-xisa [38]

Answer: True

Explanation:

Yes, it is true that the informal or the casual meetings are very common and you can chat over tea with your friends and colleagues and meet with your childhood friends in purely social meeting. Informal meetings are basically planned for relaxation your mind and mood other than formal business meetings. It does not have any agenda like the formal business meetings.

3 0
3 years ago
An IT security threat is anything that might cause serious harm to a computer system.
Blababa [14]

Answer:

True

Explanation:

this is true because a threat can endanger the computer and its system

5 0
2 years ago
What dose it need For a device to be considered a kind of computer
const2013 [10]

Answer:

Micro controller or MCU (Microcontroller Unit)

Explanation:

Micro Controller Unit is basically a computer on a chip with all components fabricated onto it. It is the core component of a computer.

A Micro Controller has:

  • Central Processing Unit CPU
  • Random access memory RAM
  • Read-only memory ROM
  • I/O peripherals
  • Timers
  • Serial COM ports

all fabricated on a single chip so that it may be connected via buses for providing the desired functionality.

<h3>I hope it will help you!</h3>
8 0
3 years ago
Read 2 more answers
In which generation of computers are we in?​
qwelly [4]
It should be the Sixth generation
4 0
3 years ago
Other questions:
  • you were discussing software privacy with a friend were surprised to learn how software privacy can impact your life everyday. w
    10·1 answer
  • Which of the following could be defined as a general-purpose computing device that enables workers to create, manage, store, sea
    12·1 answer
  • An organization uses SAP financial management software to store accounting details and Microsoft CRM software to record customer
    12·1 answer
  • Write a C++ program in which you declare variables that will hold an hourly wage, a number of hours worked, and a withholding pe
    12·1 answer
  • My question is do you learn how to do a voice over in technology?
    14·1 answer
  • Using this tool to help you to visualize your slides and develop your content
    13·1 answer
  • Why, y did brainly just do that........or did it just happen to me
    12·2 answers
  • If you wanted to make the system sequentially consistent, what are the key constrains you need to impose
    6·1 answer
  • Excel files have a default extension of ?
    12·1 answer
  • Suppose that a particular algorithm has time complexity T(n) = 3 \times 2^nT(n)=3×2 ​n ​​ and that executing an implementation o
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!