Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Important notes for the functions you implement: your functions should not modify the lists passed as arguments you cannot use list comprehension or lambda functions

image text in transcribed
image text in transcribed
Important notes for the functions you implement: your functions should not modify the lists passed as arguments you cannot use list comprehension or lambda functions in your code (if you don't know what these are that's okay, just solve the problems as we do during lecture) . 1. Design a function called sum_squares that takes a list of integers as an argument. The function returns the sum of the square of all integers in the list. For example: sum_squares([7, 0, 1, 3]) returns 59, since 72 +02 +12 +32 = 59 2. Design a function called doubled_list that takes a list of integers as an argument. The function creates a new list that contains all of the elements in the original list with their values doubled. For example: doubled_list([7, 0, 1, 3]) returns a new list: [14, 0, 2, 6]. a. 3. Design a function called count_multiples that takes two arguments: a list of integers to search through b. an integer to find the multiples of The function calculates and returns the number of multiples of the given integer in the list. For example: count_multiples ([8, 9, 10, 12, 15], 2) returns 3, since the list contains three integers that are multiples of 2 (8, 10, and 12). 4. Design a function called sum_positive that takes a list of integers as an argument. The function returns the sum all of the positive integers found in the list. For example: sum_positive([7, 0, -6, 3, -4]) returns 10, since 7+3 = 10. a. 5. Design a function called list_with_prefix that takes two arguments: a list of strings to search through b. a prefix string to add to the front of each word in the list The function creates and returns a new list, where each element in the new list has had the prefix string added to the front of the string from the original list. For example: list_with_prefix(['fine', 'lay', 'spite', 'tail'], "re") creates and returns a new list: ['refine', 'relay', 'respite', 'retail'] Whereas: list_with_prefix(['fine', 'lay', 'spite', 'tail'], "de") creates and returns a new list: ['define', 'delay', 'despite', 'detail'] 6. Design a function called all_long_enough that takes two arguments: a. a list of strings to search through b. an integer representing the minimum allowable string length The function determines if all of the strings in the list meet the minimum length requirement. For example: all_long_enough(['this', 'is', 'so', 'fun'], 2) returns True, since all of the strings are at least length 2, but if the second argument was a 3 it would return False, since 'is! and 'so' are only two letters long. 7. Design a function called growing_strings that takes a list of strings as an argument. The function determines whether the strings are sorted in ascending order according to their length. For example: growing_strings(['tiny', 'same', 'small', 'bigger']) returns True since the strings lengths are sorted (lengths of 4, 4, 5, 6). On the other hand: growing_strings(['big', 'bigger', 'biggest', 'huge']) returns False, since the strings lengths are not sorted in ascending order (lengths of 3.6.7. 4)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Horse Betting The Road To Absolute Horse Racing 2

Authors: NAKAGAWA,YUKIO

1st Edition

B0CFZN219G, 979-8856410593

More Books

Students also viewed these Databases questions