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
I am to write a function in python that will return a List L of 2 values that are equal to an integer called s. Lets say L = [1,5,2,7] and s = 12. I want the function to return [5,7] and if the list does not have values that are equal to s, it should return an empty List. want it to run in O(n) time.
Starting function:
def sum_of_two(L,s):
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 4 steps with 2 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
- Use Python when answering the question: Write a function primeFac that computes the prime factorization of anumber: it accepts a single argument, an integer greater than 1 it returns a list containing the prime factorization each number in the list is a prime number greater than 1 the product of the numbers in the list is the original number the factors are listed in non-decreasing order Output is in the attached picture:arrow_forwardWrite a function called get_palindromes() that takes a list of words as input. The function should return a new list containing every word in the input list that is a palindrome (a palindrome is a word that reads the same forwards and backwards, like "noon" or "eve"). The output list should be a list of tuples, where each tuple consists of a palindrome and its length. NOTE: You must use a list comprehension to solve this exercise. Your function must be defined as a *single line* of code - CodeRunner will count the number of "new lines" inside your function definition, and there must be only one new line (separating the function header from the function body). The code editor below should show only two lines: one for the function header and one for the function body. Delete any blank lines within the function definition and do not add a new line at the end of the function body (i.e. at the end of the return statement)! For example: Test words = ["noon", "bob", "ann"] result =…arrow_forward-python- Write a function called get_words that takes a list of words and a letter,and returns a new list, which only contains the words that don't have the given letter in them. For example, get_words(["cat", "dog"], 'o') should return ["cat"] and get_words(["cat", "bat"], 'a') should return an empty list.arrow_forward
- 1.Given the argument passed to the function is a list containing integer values, what does the function return def mystery1(someListOfValues: list):total = 0for value in someListOfValues:total += valuereturn total/len(someListOfValues) 2. The function below is to find the largest value in a list passed by parameter. Does it work as intened (yes or no)? If not give an example of an argument it would not work for. def maxValue(someListOfValues:list):"""returns the largest value the list passed by parameter"""value = 0for num in someListOfValues:if num > value:value = numreturn value 3.Write a function called loadNames() that will open a file called names.txt and build a list of its contents and return it. Function Call: names = loadNames()print(names) Sample ouput: ['Nolan Rafaj\n', 'Brandon Brzuszkiewicz\n', 'Amanda Vozari\n', 'Chase Harper\n', 'Bryce Conner']arrow_forwardIn python We have a list (named data) of numbers sorted in ascending order, for example: data = [2, 4, 5, 9, 10, 12, 13, 17, 18, 20] Write a function (named DataVar(data)), which take a list (data) as input parameter and performs the following steps on the list: 1) it finds the mean m of the data (for the given example, it is m = (2 + 4 + 5 + 9 + 10 + 12 + 13 + 17 + 18 + 20)/10 =110/10 = 11). 2) then, it finds the difference of data and m. Essentially, it finds for all data: Diff = data-m For the given example, Diff = [-9, -7, -6, -2, -1, 1, 2, 6, 7, 9]. 3) then, it finds the sum of Diff and 7. Essentially, it finds for all data: Sums = Diff+7 For the given example, Sums = [-2, 0, 1, 5, 6, 8, 9, 13, 14, 16]. 4) then, it finds the square of all the elements of Sums, such that Squares = square of the elements of Sums. For the given example, Squares = [4, 0, 1, 25, 36, 64, 81, 169, 196, 256]. 5) it finds the average of Squares and stores it in result, and returns it. For the given…arrow_forwardCan you use Python programming language to to this question? Thanksarrow_forward
arrow_back_ios
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