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
7. In order to check your following distance, use a fixed object and count seconds.
rewona [7]

Answer:

False

Explanation:

7 0
3 years ago
Read 2 more answers
Suppose that a main method encounters the statement t3.join(); Suppose that thread t3's run() method has completed running. What
Slav-nsk [51]

Answer:

C. The main method proceeds to the next statement following the t3.join(); statement

Explanation:

join() method allows the thread to wait for another thread and completes its execution. If the thread object is executing, then t3.join() will make that t is terminated before the program executes the instruction. Thread provides the method which allows one thread to another complete its execution. If t is a thread object then t.join() will make that t is terminated before the next instruction. There are three overloaded functions.

join()

join(long mills)

join(long millis, int Nanos)

If multiple threads call the join() methods, then overloading allows the programmer to specify the period. Join is dependent on the OS and will wait .

8 0
3 years ago
A palindrome is a string that reads the same both forward and backward. For example, the string madam is a palindrome. Write a p
miskamm [114]

Answer:

Explanation: Hey bro! Sorry to bother. But have any of your questions got deleted after posting them? I don't know why my question got deleted by a guy.

8 0
3 years ago
An executive at an online video company wants to look over usage data from the previous month. The company has data from
aleksklad [387]

Answer:

We first need to find out the number of variables, and if it is 3 or less, we can use excel for visualization or else we need to make use of the Microsoft Power BI or Tableau. And here, we have one variable as subscribers in various age groups, and the second variable is the number of hours spent in watching videos. And hence, we have only two variables. And thus, we can make use of the bar chart for visualization, and that is quite enough for visualizing this case. However, remember visualization is done for analyzing, and analyzing is made easy through visualization.

Explanation:

Please check the answer.

7 0
3 years ago
Read 2 more answers
G The method of mapping where each memory locationis mapped to exactly one location in the cache is
Otrada [13]

Answer:

Direct Mapped Cache

Explanation:

Given that a Direct Mapped Cache is a form of mapping whereby each main memory address is mapped into precisely one cache block.

It is considered cheaper compared to the associative method of cache mapping, and it is faster when searching through it. This is because it utilizes a tag field only.

Hence, The method of mapping where each memory location is mapped to exactly one location in the cache is "Direct Mapped Cache"

4 0
3 years ago
Other questions:
  • One difference between setters and getters is: a setter has one or more parameters; a getter has no parameters.
    15·1 answer
  • Derek has an interest in designing video games. What requirements should he fulfill to be a game designer?
    13·1 answer
  • What are the advantages of a diverse workforce? Select all that apply.
    6·2 answers
  • When viewing data entered into a spreadsheet, the columns identify _____.?
    5·1 answer
  • Which is a type of display monitor? HDD CPU SSD LCD
    6·1 answer
  • what programs controls all operations of the computer hardware such as memory storage devices or printers and provides for you t
    7·1 answer
  • 1. What type of malware is triggered by a specific condition, such as a specific date or a particular user account being disable
    6·1 answer
  • Which object event is an indication that something has been created but not committed into the database?
    13·1 answer
  • Select the correct answer from each drop-down menu. The following diagram shows four resistors. What is the effective resistance
    9·1 answer
  • how does the use of data abstraction manage complexity in program code? how does using lists make a program easier to develop an
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!