Question

In: Computer Science

In a program, write a function that accepts two arguments: a list, and a number n....

In a program, write a function that accepts two arguments: a list, and a number n. Assume

that the list contains numbers. The function should display all of the numbers in the list that

are greater than the number n.

The program should ask for a list of numbers from the user as well as a value (a, b, c)--> inputs from user. After that, each number in that list should be compared to that value (a or b or c).

Solutions

Expert Solution

#source code in python:

def datafun(lst,nval):

out=[]

for i in lst:

if i>nval:

out.append(i)

return out

if __name__=="__main__":

sub=[]

n=int(input("Enter length of list:"))

v=int(input("Enter value:"))

for i in range(n):

val=int(input("Enter the element:"))

sub.append(val)

print("The Created list:",sub)

print("The value:",v)

out=datafun(sub,v)

print("The output list:",out)

#if you have any doubt or more information needed comment below..i will respond as possible as soon..thanks.


Related Solutions

Write a function that accepts two arguments (say a and b) by value and one argument...
Write a function that accepts two arguments (say a and b) by value and one argument (say c) by reference. Then it calculates the multiplication of all the numbers between a and b (inclusive) and saves the results in c. The function does not return any value.
program c Write a program called filesearch that accepts two command-line arguments: A string A filename...
program c Write a program called filesearch that accepts two command-line arguments: A string A filename If the user did not supply both arguments, the program should display an error message and exit. The program opens the given filename. Each line that contains the given string is displayed. Use the strstr function to search each line for the string. You may assume no line is longer than 255 characters. The matching lines are displayed to standard output (normally the screen).
Write a function that accepts an int array and the array's size as arguments.
Write a function that accepts an int array and the array's size as arguments. The function should create a copy of the array, except that the element values should be reversed int the copy. The function should return a pointer to the new array. Demonstrate the function in a complete program.  
a) Write a function drawShape() that accepts a parameter n, and: If n is odd, it...
a) Write a function drawShape() that accepts a parameter n, and: If n is odd, it constructs a pattern of a diamond of height n If n is even, it constructs an hourglass of length n b) What is the time complexity of the drawShape() function you created? C++ language with for loop
Using Python #Write a function called after_second that accepts two #arguments: a target string to search,...
Using Python #Write a function called after_second that accepts two #arguments: a target string to search, and string to search #for. The function should return everything in the first #string *after* the *second* occurrence of the search term. #You can assume there will always be at least two #occurrences of the search term in the first string. # #For example: # after_second("11223344554321", "3") -> 44554321 # #The search term "3" appears at indices 4 and 5. So, this #returns everything...
Write a Python function that accepts three arguments: an array, the size of the array, and...
Write a Python function that accepts three arguments: an array, the size of the array, and a number n. Assume that array contains integers. The function should display all integers in the array that are greater than the number n. Test your function.
C++ Write a function that accepts an array of doubles and the array's size as arguments....
C++ Write a function that accepts an array of doubles and the array's size as arguments. The function should display the contents of the array to the screen.
In this third part, write a function that accepts an array of integers and its size as arguments.
in C++In this third part, write a function that accepts an array of integers and its size as arguments. The function should create a new array that is of half size the argument array (round up the fraction if the size of the argument array is odd). The value of the first element (Element 0) of the new array should be the sum of the first two elements of the argument array (Element 0 and 1). Element 1 of the...
Element Shifter: Write a function that accepts an int array and the array’s size as arguments....
Element Shifter: Write a function that accepts an int array and the array’s size as arguments. The function should create a new array that is one element larger than the argument array. The first element of the new array should be set to 0. Element 0 of the argument array should be copied to element 1 of the new array, element 1 of the argument array should be copied to element 2 of the new array, and so forth. The...
Write a function called compute_pay that accepts arguments representing the hourly wage of an employee and the number of hours that employee worked this week.
Python RephactorCompute Take Home PayWrite a function called compute_pay that accepts arguments representing the hourly wage of an employee and the number of hours that employee worked this week. The function should return the take home pay owed to the employee as a floating point value rounded to two decimal places.The normal work week is 40 hours, and the company pays employees "time and a half" for overtime. So, the total wages is the sum of regular wages and overtime...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT