Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
Answer fast….
create a python functions outlined below
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, it should return a list of strings of numbers. 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 to the current string's index+1. The number in the string should be repeated the 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:list, 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.
Example:
Colors: {'black', 'pink', 'yellow'}
List: [('green', 100), ('yellow', 13), ('red', 6)]
Expected: [13]
Colors: {'yellow'}
List: [('black', 54), ('pink', 5)]
Expected: []
Colors: {'black', 'blue', 'yellow'}
List: [('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
concatenate_dict(dict_list:list)->dict
This function will be given a single parameter known as the Dictionary List. Your job is to combine all the dictionaries found in the dictionary list into a single dictionary and return it. There are two rules for adding values to the dictionary:
You must add key-value pairs to the dictionary in the same order they are found in the Dictionary List.
If the key already exists, it cannot be overwritten. In other words, if two or more dictionaries have the same key, the key to be added cannot be overwritten by the subsequent dictionaries.
Example:
Dictionary List: [{'Z': 6, 'k': 10, 'w': 3, 'I': 8, 'Y': 5}, {'Y': 1, 'Z': 4}, {'X': 2, 'L': 5}]
Expected: {'Z': 6, 'k': 10, 'w': 3, 'I': 8, 'Y': 5, 'X': 2, 'L': 5}
Dictionary List: [{'z': 0}, {'z': 7}]
Expected: {'z': 0}
Dictionary List: [{'b': 7, 'b': 10, 'A': 8, 'Z': 2, 'V': 1}]
Expected: {'b': 7, 'A': 8, 'Z': 2, 'V': 1}
unique_values(a_dict:dict)-> dict
This function will receive a single dictionary parameter known as a_dict. a_dict will contain a single letter as a string and numbers as values. This function is supposed to search a_dict to find all values that appear only once in the a_dict. The function will create another dictionary named to_ret. For all values that appear once in a_dict the function will add the value as a key in to_ret and set the value of the key to the key of the value in a_dict (swap the key-value pairs, since a_dict contains letters to numbers, to_ret will contain Numbers to Letters). Finally, the function should return to_ret.
Example:
a_dict: {'X': 2, 'Y': 5, 'N': 2, 'L': 2, 'W': 1, 'G': 0, 'R': 1}
Expected: {5: 'Y', 0: 'G'}
a_dict: {'Z': 3, 'P': 3, 'E': 2, 'G': 0, 'T': 5, 'L': 1, 'Q': 0}
to_ret: {2: 'E', 5: 'T', 1: 'L'}
a_dict: {'E': 3, 'X': 3}
to_ret: {}
a_dict: {'G': 3, 'D': 3, 'C': 4, 'Q': 1, 'H': 1, 'M': 2, 'Z': 1, 'W': 3}
to_ret: {4: 'C', 2: 'M'}
a_dict: {'O': 2, 'T': 1, 'L': 5, 'W': 5, 'Z': 4, 'M': 5, 'B': 4, 'D': 0, 'F': 3, 'E': 1}
to_ret: {2: 'O', 0: 'D', 3: 'F'}
dict_from_string(dict_str:str)->dict
This function will be given a single parameter, a string representing a dictionary. Your job is to convert the string into an actual dictionary and return the dictionary. Make sure all key-value pairs in the string exist in the newly created dictionary. The string will contain only numbers or single letters as key values pairs. Make sure all letters are kept as strings and all numbers are converted to integers in the newly created dictionary.
Example:
String Input: '{9: 'V', 'G': 0, 'M': 9, 'u': 3, 2: 'o', 8: 'u', 'q': 9, 'D': 1}'
Expected: {9: 'V', 'G': 0, 'M': 9, 'u': 3, 2: 'o', 8: 'u', 'q': 9, 'D': 1}
String Input: '{10: 'D', 1: 'Z', 5: 'a'}'
Expected: {10: 'D', 1: 'Z', 5: 'a'}
String Input: '{'M': 2, 'V': 0, 3: 'x', 6: 'J', 5: 'J', 7: 'T', 8: 'P', 4: 'q', 1: 'h'}'
Expected: {'M': 2, 'V': 0, 3: 'x', 6: 'J', 5: 'J', 7: 'T', 8: 'P', 4: 'q', 1: 'h'}
String Input: '{3: 'D', 10: 'T', 7: 'm', 'u': 9, 't': 5, 6: 'Z', 'H': 10, 'B': 6}'
Expected: {3: 'D', 10: 'T', 7: 'm', 'u': 9, 't': 5, 6: 'Z', 'H': 10, 'B': 6}
String Input: '{'q': 10, 6: 'O', 'm': 6}'
Expected: {'q': 10, 6: 'O', 'm': 6}
flip_matrix(mat:list)->list
You will be given a single parameter a 2D list (A list with lists within it) this will look like a 2D matrix when printed out, see examples below. Your job is to flip the matrix on its horizontal axis. In other words, flip the matrix horizontally so that the bottom is at top and the top is at the bottom. Return the flipped matrix.
To print the matrix to the console:
print('\n'.join([''.join(['{:4}'.format(item) for item in row]) for row in mat]))
Example:
Matrix:
W R I T X
H D R L G
L K F M V
G I S T C
W N M N F
Expected:
W N M N F
G I S T C
L K F M V
H D R L G
W R I T X
Matrix:
L C
S P
Expected:
S P
L C
Matrix:
A D J
A Q H
J C I
Expected:
J C I
A Q H
A D J
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 5 steps with 4 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Python Qu Write a Python program (not a function!) that asks the user for nonnegative integers,one integer per line.When the user is finished entering their integers, they enter a negative integerto tell the program to stop asking them for more integers.Once the input is complete, the program prints "No integers to average"if the user provided no nonnegative integers,and the average of the nonnegative integers otherwise.You must NOT use lists, tuples, or dictionaries in your code.Here is a sample program run where the user enters 4 and then 8 and then -1.The program outputs Average: 6.048-1Average: 6.0Here is another run where the user types -3 to the first prompt.The program outputs No integers to average-3No integers to averagearrow_forwardWrite the code in python Design a problem that asks user to enter a series of 6 numbers. The program should store the numbers in a list then display the following data: The lowest number in the list The highest number in the list The total of numbers in the list The average of the numbers in the list.arrow_forwardCan you use Python programming language to to this question? Thanksarrow_forward
- Im Python pleasearrow_forwardIn python, Problem Description:You are hosting a party and do not have room to invite all of your friends. You use the following unemotional mathematical method to determine which friends to invite. Number your friends 1, 2, . . . , K and place them in a list in this order. Then perform m rounds. In each round, use a number to determine which friends to remove from the ordered list. The rounds will use numbers r1, r2, . . . , rm. In round i remove all the remaining people in positions that are multiples of ri (that is, ri, 2ri, 3ri, . . .) The beginning of the list is position 1. Output the numbers of the friends that remain after this removal process. Input Specification:The first line of input contains the integer K (1 ≤ K ≤ 100). The second line of input contains the integer m (1 ≤ m ≤ 10), which is the number of rounds of removal. The next m lines each contain one integer. The ith of these lines (1 ≤ i ≤ m) contains ri ( 2 ≤ ri ≤ 100) indicating that every person at a position…arrow_forwardPython code please help, indentation would be greatly appreciatedarrow_forward
- Python programming only NEED HELP PLEASEarrow_forwardpython LAB: Subtracting list elements from max When analyzing data sets, such as data for human heights or for human weights, a common step is to adjust the data. This can be done by normalizing to values between 0 and 1, or throwing away outliers. Write a program that adjusts a list of values by subtracting each value from the maximum value in the list. The input begins with an integer indicating the number of integers that follow.arrow_forwardPython Help Write a program that reads numbers and adds them to a list if the are not already contained in the list. When the list contains ten numbers, the program displays the contents and quits. Show the analysis, specifications and flowcharts of the two problems Use documentation by commenting your code Write your code in the script modearrow_forward
- The function sum_evens in python takes a list of integers and returns the sum of all the even integers in the list. For example: Test Result print(sum_evens([1, 5, 2, 5, 3, 5, 4])) 6 print(sum_evens([5, 5, -5, -5])) 0 print(sum_evens([16, 24, 30])) 70arrow_forwardThe function should be written in python language. Write a function called "zero_triples" to return all triples in a list of integers that sum to zero. You can assume the list won't contain any duplicates, and a triple should not use the same number more than once. [In]: zero_triples([1, 2, 4]) [Out]: [] [In]: zero_triples([-3, 1, 4, 2]) [Out]: [[1, 2, -3]] [In]: zero_triples([-9, 1, -3, 2, 4, 5, -4, -1]) [Out]: [[-9, 4, 5], [1, -3, 2], [-3, 4, -1], [5, -4, -1]]arrow_forwardPYTHON Complete the function below, which takes two arguments: data: a list of tweets search_words: a list of search phrases The function should, for each tweet in data, check whether that tweet uses any of the words in the list search_words. If it does, we keep the tweet. If it does not, we ignore the tweet. data = ['ZOOM earnings for Q1 are up 5%', 'Subscriptions at ZOOM have risen to all-time highs, boosting sales', "Got a new Mazda, ZOOM ZOOM Y'ALL!", 'I hate getting up at 8am FOR A STUPID ZOOM MEETING', 'ZOOM execs hint at a decline in earnings following a capital expansion program'] Hint: Consider the example_function below. It takes a list of numbers in numbers and keeps only those that appear in search_numbers. def example_function(numbers, search_numbers): keep = [] for number in numbers: if number in search_numbers(): keep.append(number) return keep def search_words(data, search_words):arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education