Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

reverse_number_in_list(number_list:list)-> list This function will be given a list of numbers your job is to reverse all the numbers in the list and return a

reverse_number_in_list(number_list:list)-> list

This function will be given a list of numbers your job is to reverse all the numbers in the list and return a list with the reversed numbers. If a number ends with 0 you need to remove all the trailing zeros before reversing the number. An example of reversing numbers with trailing zeros:10 -> 1,590 -> 95. None of the numbers in the number_list will be less than 1.

Example:

number_list = [13, 45, 690, 57]

output = [31, 54, 96, 75]

tails_same(number_list:list) -> bool

This function should return true if the value at the beginning and the end of the list are equal. False otherwise.

Example:

number_list = [1, 239, 949, 0, 84, 0, 1]

output: True

number_list = [1, 239, 949, 0, 84, 0, 13]

output: False

remove_char(str_list:list,char:str) -> list

This function will be given a list of strings and a character. You must remove all occurrences of the character from each string in the list. The function should return the list of strings with the character removed.

Example:

str_list= ['adndj', 'adjdlaa', 'aa', 'djoe']

char: a

output =['dndj', 'djdl', '', 'djoe']

return_growing_num_list(max:int) -> list

This function will be given a single number, itshould return a list of strings ofnumbers. Each string in the list will only contain a single number repeated an arbitrary amount of times. The number each string will contain will be equal tothe current string's index+1. The numberin the string should berepeatedthe same number of times as the string's index+1. Each number in the string should be separated by a space. This list should stop when its size equals the max number specified.

Example:

max = 3

output = ['1', '2 2', '3 3 3']

max = 4

output= ['1', '2 2', '3 3 3', '4 4 4 4']

find_color(colors:set, values:list) -> list

The function will have two parameters. The first parameter is a set of strings known as Colors. A second parameter is a list of tuple-2 known as Values. Colors will contain a set of randomly selected colors. Values will contain a list of tuples of size 2. Each tuple will contain color (str) and a number (int). The function should look at each tuple in Values. For each tuple, add the number (the second value in the tuple) to a list of numbers if the color in the tuple (the first value in the tuple) is in Colors. In other words, find all tuples that have a color in the Colors and add the tuples numbers to a list. Finally, the function should return the list of numbers collected in the order they are found in the values list.

Example:

Colors: {'black', 'pink', 'yellow'}

values: [('green', 100), ('yellow', 13), ('red', 6)]

Expected: [13]

Colors: {'yellow'}

values: [('black', 54), ('pink', 5)]

Expected: []

Colors: {'black', 'blue', 'yellow'}

values: [('yellow', 29), ('yellow', 19), ('black', 31), ('yellow', 67), ('green', 44)]

Expected: [29, 19, 31, 67]

dict_contains_keys(items:set, example_dict:dict)->bool

This function will have two parameters. The first is a set of numbers known as Number Set. The second is a dictionary known as Dictionary. Dictionary will have keys as integers and values as letters. The functions should return true if at least one of the numbers in the Number set is a key in Dictionary. It should return false otherwise.

Example:

Items: {8, 10, 5}

Example: {9: 'F', 10: 'X'}

Expected: True

Items: {8, 9, 5, 1}

Example: {6: 'i', 5: 'Y', 1: 'N', 0: 'E'}

Expected: True

Items: {9, 10, 4}

Example: {5: 'i', 3: 'o', 1: 'N'}

Expected: False

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Microeconomics

Authors: Douglas Bernheim, Michael Whinston

2nd edition

73375853, 978-0073375854

Students also viewed these Economics questions