Question
It's in Python 3. Please make sure it displays correct strings lenght
1 def sum list(numbers): Sums a list of integers param numbers: a list of intege rs return: the sum of the integers in numbe
At this point, if you try to run the file, you will get an error. That is because the file is only partially completed for yo

And displays correct character lenght
0 0
Add a comment Improve this question Transcribed image text
Answer #1

def sum_list(numbers):
total=0
for i in numbers:
total+=i
return total

def get_string_lengths(strings):
return [len(i) for i in strings]

def get_names():
names=[]
name=input('Enter a name, STOP to stop: ')
while name!='STOP':
names.append(name)
name=input('Enter a name, STOP to stop: ')
return names

if __name__=='__main__':
kitties=["Jules","Stubby","Tyball","Scooter","KC","Garfield","Bucky"]
print('There are {} letters in kitties.'.format(sum_list(get_string_lengths(kitties))))
puppers=["Charlie","Chuck","Chuckadero","Char","Charmander","Charles, Lord of Hearts, King of snuggles"]
print('There are {} letters in puppers.'.format(sum_list(get_string_lengths(puppers))))
print('There are {} letters in the names you entered.'.format(sum_list(get_string_lengths(get_names()))))

Python 3 O Help File Edit View Insert Cell Kernel Widgets Trusted In [8] def sum_list(numbers) total-0 for i in numbers: tota

Add a comment
Know the answer?
Add Answer to:
It's in Python 3. Please make sure it displays correct strings lenght And displays correct character...
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
  • Simple Python Program Working with strings Write a Python program to read in a number of...

    Simple Python Program Working with strings Write a Python program to read in a number of strings from the user. Stop when the user enters “Done”. Then check if each of the strings contains all the letters of the alphabet. Print the results in the form of a dictionary, where they keys are the strings and the values are the Truth Value for the string, which you just calculated. Sample Run: Enter the strings: taco cat The quick brown fox...

  • Could anyone please help with this Python code assignment? In this programming assignment you are to...

    Could anyone please help with this Python code assignment? In this programming assignment you are to create a program called numstat.py that reads a series of integer numbers from a file and determines and displays the following: The name of the file. The sum of the numbers. The count of how many numbers are in the file. The average of the numbers. The average is the sum of the numbers divided by how many there are. The maximum value. The...

  • Python: Write a program that lets the user enter a string and displays the letter that...

    Python: Write a program that lets the user enter a string and displays the letter that appears most frequently in the string, ignore spaces, punctuation, and Upper vs Lower case. Create a list to hold letters based on the length of the user input Convert all letters to the same case Use a loop to check for each letter in the alphabet Have a variable to hold the largest number of times a letter appears, and replace the value when...

  • python 3 8.12 LAB: Python cross reference In addition to editors and compilers, a software developer...

    python 3 8.12 LAB: Python cross reference In addition to editors and compilers, a software developer may use tools to analyze the software they are writing to examine the names being used for variables and functions, and list the line numbers where the variables and functions names appear. For example, consider the following program savings.py used to compute the month to month interest gained from a certificate of deposit: 1: Input the CD APR, no years and initial deposit 2:...

  • Python 3.7.3 ''' Problem 3 Write a function called names, which takes a list of strings...

    Python 3.7.3 ''' Problem 3 Write a function called names, which takes a list of strings as a parameter. The strings are intended to represent a person's first and last name (with a blank in between). Assume the last names are unique. The function should return a dictionary (dict) whose keys are the people's last names, and whose values are their first names. For example: >>> dictionary = names([ 'Ljubomir Perkovic', \ 'Amber Settle', 'Steve Jost']) >>> dictionary['Settle'] 'Amber' >>>...

  • Python code. No use of def() or return. 7a)Create a program that asks the user for...

    Python code. No use of def() or return. 7a)Create a program that asks the user for their full name (first, middle, and last). You can assume that compound names, such as Jamie-Lynn are joined by a hyphen, that names are separated by a space and that the user enters their data in the correct format. The program should then separate the first name, middle name, and last name from the single string entered by the user and save each piece...

  • Finish the given ProcessFile.java program that prompts the user for a filename and reprompts if file...

    Finish the given ProcessFile.java program that prompts the user for a filename and reprompts if file doesn’t exist. You will process through the file skipping any text or real (double) numbers. You will print the max, min, sum, count, and average of the integers in the file. You will want to create test files that contain integers, doubles, and Strings. HINT: Use hasNextInt() method and while loop. You may also want to use Integer.MAX_VALUE and Integer.MIN_VALUE for the initialization of...

  • Python program. Character-Analysis Program Problem Statement: Design a program - IN PYTHON - that asks the...

    Python program. Character-Analysis Program Problem Statement: Design a program - IN PYTHON - that asks the user to enter a string. The string will then be displayed back to the user. This is followed by determining the number of alphabetic characters, numeric characters, lower_case letters, upper_case letters, whitespace characters, and then displaying them. The user should be given additional chances to enter additional strings, and each time a string is entered, the above process is to be performed. The inputting...

  • Need help with the code for this assignment. Python Assignment: List and Tuples We will do...

    Need help with the code for this assignment. Python Assignment: List and Tuples We will do some basic data analysis on information stored in external files. GirNames.txt contains a list of the 200 most popular names given to girls born in US from year 2000 thru 2009: (copy link and create a txt file): https://docs.google.com/document/d/11YCVqVTrzqQgp2xJqyqPruGtlyxs2X3DFWn1YUb3ddw/edit?usp=sharing BoyNames.txt contains a list of the 200 most popular names given to boys born in US from year 2000 thru 2009 (copy link and create...

  • Using PYTHON: (Find the index of the smallest element) Write a function that returns the index...

    Using PYTHON: (Find the index of the smallest element) Write a function that returns the index of the smallest element in a list of integers. If the number of such elements is greater than 1, return the smallest index. Use the following header: def indexOfSmallestElement(lst): Write a test program that prompts the user to enter a list of numbers, invokes this function to return the index of the smallest element, and displays the index. PLEASE USE LISTS!

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