Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In Python, In a program write a function that accepts two arguments: a list, an

ID: 3807593 • Letter: I

Question

In Python, In a program write a function that accepts two arguments: a list, an 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. Here is what I have so far.

#call the main function
def main:
    #declares local variables
    number = 5
    number_list = [1,2,3,4,5,6,7,8,9,10]
#displays the number
    print('Number', number)
    #displays the list of numbers
    print('List of numbers:/n', number_list, sep='')
    #Display the list of numbers that are larger
    #than the number
    print('List of numbers that are larger than',
          number, ':', sep='')
    #Call the larger_than_n_list function,
    #passing a number and number list as arguments.
    display_larger)than_n_list(number, number_list)
    # The display_largger_than_n_list function acceps two arguments:
    #a list, and a number. The function displays all of the numbers
    #in the list that are greater than that number.
def display_larger_than_n_list(n, n_list):
    #Declare an empty list
    larger_than_n_list = []
    #Loop through the values in the list.
    for valie in n_list:
        #Determins if a value is greatter than n.
        dont know what goes here
            #if so, append the value to the list
        larger_than_n_list.append(value)
    #Display the list.
        print("larger_than_n_list")
    #Call the main function
main()

Explanation / Answer

Hi

I have fixed the issue and highlighted the code changes below

def main():
#declares local variables
number = 5
number_list = [1,2,3,4,5,6,7,8,9,10]
#displays the number
print('Number', number)
#displays the list of numbers
print('List of numbers:/n', number_list, sep='')
#Display the list of numbers that are larger
#than the number
print('List of numbers that are larger than',
number, ':', sep='')
#Call the larger_than_n_list function,
#passing a number and number list as arguments.
display_larger_than_n_list(number, number_list)
# The display_largger_than_n_list function acceps two arguments:
#a list, and a number. The function displays all of the numbers
#in the list that are greater than that number.
def display_larger_than_n_list(n, n_list):
#Declare an empty list
larger_than_n_list = []
#Loop through the values in the list.
for valie in n_list:
#Determins if a value is greatter than n.
if valie > n:
print(valie)
#Call the main function
main()

Output:

sh-4.3$ python3 main.py                                                                                                                                                                                                                                                  

Number 5                                                                                                                                                                                                                                                                 

List of numbers:/n[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]                                                                                                                                                                                                                        

List of numbers that are larger than5:                                                                                                                                                                                                                                   

6                                                                                                                                                                                                                                                                        

7                                                                                                                                                                                                                                                                        

8                                                                                                                                                                                                                                                                        

9                                                                                                                                                                                                                                                                        

10

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote