1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
nlexa [21]
3 years ago
7

In Python, In a program write a function that accepts two arguments: a list, an a number n. Assume that the list contains number

s. 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()

Computers and Technology
1 answer:
Anton [14]3 years ago
8 0

Answer:

#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 value in n_list:

       #Determine if a value is greatter than n.

       # dont know what goes here

       #if so, append the value to the list

       if (value > n):

           larger_than_n_list.append(value)

   #Display the list.

   print(larger_than_n_list)

#Call the main function

main()

Explanation:

The above is the corrected code and it works properly. Some of the errors noted and corrected include:

  • omission of bracket from of main. It should be main()
  • displaying larger_than_n_list as a string instead of a list reference. It should be print(larger_than_n_list)
  • missing if-statement to compare each element in the list with the value in the argument passed.
  • missing call to the display_larger_than_n_list function

A sample image output of the code execution is attached.

You might be interested in
Which of the following is true about ethical issues in graphic design?
Basile [38]

Answer: The Answer Is B

Explanation:

I Did It On Edge

3 0
3 years ago
Read 2 more answers
Just take points, this website is so weird because of all the reporting and I didn't do any thing
krok68 [10]

Answer:

I agree with you! And thank you for the points

Explanation:

I answer educational questions and ask one of my own regarding math and it gets reported

Someone asked if their art was good and how they can improve it and it gets reported

But the only questions they don’t report are free po!nts

For the people who don’t have anything better to do then report people trying to get help: STOP ITS ANNOYING NOT JUST FOR ME BUT THE PEOPLE WHO ARE TRYING TO GET HELP, INSTEAD OF REPORTING WHY DONT U HELP PEOPLE???

7 0
3 years ago
Read 2 more answers
How do I give Brainliest?? I'll give brainliest...
Elodia [21]
Can i have it don’t think i ever got one
8 0
3 years ago
Read 2 more answers
The best way for you to communicate with the school is through
REY [17]
A. Because you can easily call the school without wasting too much time
4 0
3 years ago
What type of computer lies between micro and mainframe computer?
avanturin [10]

Answer:

Mini computer lie between micro and mainframe Computer.

Hope it will help you :)

3 0
3 years ago
Other questions:
  • What is a sound wave
    7·2 answers
  • Which answer choice correctly distinguishes among the three pieces of data?
    13·1 answer
  • ____ are programs that need to be attached to other files to install themselves on computers without the users’ knowledge or per
    5·1 answer
  • Write a generic C++ function that takes an array of genericelements and a scalar of the same type as the array elements. Thetype
    13·1 answer
  • TWO QUICK QUESTIONS
    12·1 answer
  • The word Only is absolute or qualified
    8·2 answers
  • 3. A security system uses sensors at every door and window which will set off analarm if any one of them is opened. There is als
    15·1 answer
  • When replacing a system board in a laptop, which feature is a must?
    7·1 answer
  • True or false scientists investigate and seek to explain the natural world
    14·1 answer
  • You are a teaching assistant for an introductory computer concepts course at your local community college. The instructor asks y
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!