answer.
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
Likurg_2
1 month ago
11

Define a function below called average_strings. The function takes one argument: a list of strings. Complete the function so tha

t it returns the average length of the strings in the list. An empty list should have an average of zero. Hint: don't forget that in order to get a string's length, you need the len function.
Computers and Technology
1 answer:
Natasha_Volkova [897]1 month ago
6 0

Answer:

def average_strings(lst):

   total_length = 0

   avg = 0

   for s in lst:

       total_length += len(s)

   avg = total_length/len(lst)

   return avg

Explanation:

Define a function named average_strings that takes a single argument, lst

Initialize both total length and avg variables

Utilize a for loop to iterate through lst, accumulating the length of each string into total length

Once the loop ends, compute the average by dividing the total length by the number of elements in lst

Return the computed average.

You might be interested in
Write a loop to populate the list user_guesses with a number of guesses. The variable num_guesses is the number of guesses the u
oksian1 [804]

Response:

num_guesses = int(input())

user_guesses = []

for i in range(num_guesses):

    x = int(input())

    user_guesses.append(x)

   

print(user_guesses)

Clarification:

This solution is given in Python

The initial line requests the user to input a number of guesses

num_guesses = int(input())

This line establishes an empty list

user_guesses = []

Inside this loop, each guess is taken from the user

for i in range(num_guesses):

In this line, each guess input by the user is processed

    x = int(input())

This adds the input to the list

    user_guesses.append(x)

Finally, this prints the collected user guesses    

print(user_guesses)

6 0
18 days ago
Discussion Question 10: A bank in California has 13 branches spread throughout northern California , each with its own minicompu
Harlamova29_29 [932]
The banking system that poses greater risk of vulnerabilities is the one with ten branches dispersed across California, where data resides on a central mainframe located in San Francisco. If the branches do not share data across the network, the risk of hacking is reduced. However, with a network setup, both data sharing and centralized storage increase exposure to unauthorized access.
3 0
22 days ago
Write a loop that prints each country's population in country_pop. Sample output for the given program.
zubka84 [945]

Response:

Correct script pertaining to the previous query that showcases the output.

for x, y in country_pop.items(): #this for loop iterates through the list items.

   print(str(x) + " has " + str(y) + " people") #output function to display the values.

Result:

  • This code is written in Python and produces the output required by the previous question.

Clarification:

  • The code in the previous question is intended for Python language to show the output, however, it has inaccuracies.
  • A 'for' loop is necessary, which will allow the items to be displayed one at a time.
  • The list presented is structured as key-value pairs, thus the use of the 'items' function from Python dictionaries is essential to present the list items.
  • Additionally, two variables must be established in the for loop, one representing the key and the other representing the value.
7 0
26 days ago
You encounter another boat. You assess the situation and determine that you are the stand-on vessel. What must you do?
maria [879]

Answer

Continue on your current heading and maintain your speed unless the vessel required to give way does not act.

Explanation

When two vessels approach each other, the one positioned on the right side is designated as the stand-on vessel, which means the other vessel, the give-way vessel, must yield. In this circumstance, you should keep your course and speed unless the give-way vessel fails to do so. If that happens, you must take evasive maneuvers to avoid collision by steering clear, never turning toward or crossing in front of the other vessel.

7 0
1 month ago
Read 2 more answers
Write a code segment to change the name of the Thing object something such that the new name consists of the old name with one c
oksian1 [804]

Answer:

import random

def name_change( name: list ) -> list :

   choice = random.choice( name )

   choice_index = name.index( choice )

   name.pop( choice_index )

   return name

Explanation:

The provided Python code utilizes the random library to randomly select an item from a list within the function "name_change". The index of the selected item is then retrieved from the list and removed from the original list called "name", with the modified name subsequently returned.

To activate the function, assign it to a variable, supply a list (it must be a list) as its argument, and then express the result.

6 0
1 month ago
Other questions:
  • 9) If you are working on the part of 5-15 minutes, time-stamping (every 30 seconds) should start at: a) [00:05:00] b) [00:00:00]
    9·1 answer
  • Marien is using the Council of Science Editors (CSE) style guidelines to write her research paper. What is her most likely topic
    13·1 answer
  • Write a loop that sets newScores to oldScores shifted once left, with element 0 copied to the end. Ex: If oldScores = {10, 20, 3
    15·1 answer
  • A company requires an Ethernet connection from the north end of its office building to the south end. The distance between conne
    8·1 answer
  • A computer program is tested by 5 independent tests. If there is an error, these tests will discover it with probabilities 0.1,
    5·1 answer
  • A developer writes a trigger on the Account object on the before update event that increments a count field. A workflow rule als
    12·1 answer
  • Fill the validateForm function to check that the phone number contains a number (use the isNaN function) and that the user name
    10·1 answer
  • Sara is writing a program to input her monthly phone bills and output the month name and amount for the month with maximum amoun
    7·1 answer
  • Describe a situation involving making a copy of a computer program or an entertainment file of some sort for which you think it
    7·1 answer
  • What feature would be used to collect how many times users downloaded a product catalog?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!