Write a Python program that includes a function that takes a list of integers and a number val as parameters and finds the index of the first number in the list greater than val.

Java Question

Write a Python program that includes a function that takes a list of integers and a number val as parameters and finds the index of the first number in the list greater than val.

Your program should contain one function:

(1) greater(lst,val): This function takes two parameters: a list of integers and a number val (int). It should return the index of the first number in the list that is greater than val. If no element of the list is greater than val, len(lst) should be returned.

(2) Outside the function, you should do the following:

a. Prompt the use multiple times to enter 5 integer elements and add them to a list called my_list. (use for loop)

b. Prompt the use to enter a number value (integer) called my_val.

c. Call the function greater() with 2 arguments: my_list and my_val. d. Print the output that the function returns.

 

Write a Python program that includes a function that takes a list of integers and a number val as parameters and finds the index of the first number in the list greater than val.
Scroll to top