Question

python Write a function named average_list() that uses a string list and outputs the av. len...

python

Write a function named average_list() that uses a string list and outputs the av. len of all the strings in the list with also the amount of strings with a len of ^ average, below, and = to avg.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
def average_list(strings):
    total = 0
    for string in strings:
        total += len(string)
    return total / len(strings)


# Testing the function here. ignore/remove the code below if not required
print(average_list(['hi', 'hello', 'how', 'are', 'you?']))

Add a comment
Know the answer?
Add Answer to:
python Write a function named average_list() that uses a string list and outputs the av. len...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • language is python Write a function named subsetStrings that has two inputs, a list of strings...

    language is python Write a function named subsetStrings that has two inputs, a list of strings and an integer n. Your function should use a single list comprehension to create a new list containing the first n characters of each string in the input list if the length of the individual string is at least n (strings that are too short should be skipped). Your function should return the new list ex: inputList 'Frederic, 'powerade', 'spring break, 'pen'] and n-4...

  • Python Write a function named letter_function. The function should accept a string (i.e., any string) and...

    Python Write a function named letter_function. The function should accept a string (i.e., any string) and display the letters in that string. For example, if the function received "python 3.2". The following letters will be displayed: (Hint: you can use s.isalpha() to know if a character is a letter) p y t h o n

  • In Python: Write the definition for a function named avg which accepts two int parameters, and...

    In Python: Write the definition for a function named avg which accepts two int parameters, and returns the average of the two values Write a statement that calls this function to print out the average of values 11 and 25.

  • 1.) Write a recursive function named isPalindrome that will take a single string as an argument...

    1.) Write a recursive function named isPalindrome that will take a single string as an argument and determine if the argument is a palindrome. The function must return True if the argument is a palindrome, False otherwise. Recall that any string is a palindrome if its first and last characters are the same and the rest of it is also a palindrome (therefore, a single character is a palindrome): 2.) Consider a text file named samplestrings.txt that contains a collection...

  • Write a Python function that will take a string and a list as its only parameters....

    Write a Python function that will take a string and a list as its only parameters. The function needs to return a new string that is the original string with all of the characters appearing in the list parameter replaced with an asterisk(*). The returned string needs to have the remaining characters appear in the same location as the characters they replaced. Hint/Reminder: Note you can make a string out of characters optimally without repeatedly using the concatenation operator.

  • Python Program 5. Write a Python program in a file named validTime.py. Include a function named...

    Python Program 5. Write a Python program in a file named validTime.py. Include a function named string parameter of the form hh:mm: ss in which these are numeric validTime that takes a values and returns True or False indicating whether or not the time is valid. The number of hours, minutes, and seconds must two digits and use a between 0 and 9). The number of hours must be between 0 and 23, the number of minutes and seconds must...

  • Write a function named words_in_both that takes two strings as parameters and returns a set of...

    Write a function named words_in_both that takes two strings as parameters and returns a set of the words contained in both strings. You can assume all characters are letters or spaces. Capitalization shouldn't matter: "to", "To", "tO", and "TO" should all count as the same word. The words in the set should be all lower-case. For example, if one string contains "To", and the other string contains "TO", then the set should contain "to". The file must be named: words_in_both.py...

  • Write a Python function called more() that takes three string inputs and outputs a string Formally,...

    Write a Python function called more() that takes three string inputs and outputs a string Formally, the function signature and output are given by rucharist, char: str words str) > str Use the same names for the input arguments as shown above Note that charl and char2 will always be a string of length 1 (ie, it is a single character. The function checks which of charl or char2 appears more often in the word string and returns that character...

  • Python: Write a function named "sort_by_average_rating" that takes a list/array of key-value stores as a parameter...

    Python: Write a function named "sort_by_average_rating" that takes a list/array of key-value stores as a parameter where each key-value store has keys "ratings", "budget", and "box_office" where budget and box_office are integers and ratings is a list of integers. Sort the input based on the average of the values in "ratings"

  • In python Write a function named printList to print the elements of a list with labels...

    In python Write a function named printList to print the elements of a list with labels showing each element's order in the list. The function header should like this: def printList(aList): And here is an example run: > > > myList = [92.5, 127.1, 9, 104.2, 78.4] > > > printList(myList) 0 92.5 1 127.1 2 9 3 104.2 4 78.4 Test your function from the Python shell window on various types of lists with varying lengths.

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT