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
Zepler [3.9K]
3 years ago
6

Write a program that first gets a list of integers from input. The input begins with an integer indicating the number of integer

s that follow Then, get the last value from the input, and output all integers less than or equal to that value. Ex: If the input is 5 50 60 140 200 75 100 the output is 50 60 75 The 5 indicates that there are five integers in the list, namely 50, 60, 140, 200, and 75. The 100 indicates that the program should output all integers less than or equal to 100, so the program outputs 50,60, and 75. Such functionality is common on sites like Amazon, where a user can filter results. Your code must define and call the following two functions def get_user_values() def output_ints_less_than_or_equal_to_threshold(user_values, upper_threshold) Utilizing functions will help to make your main very clean and intuitive. Note: This is a lab from a previous chapter that now requires the use of functions LAB ACTIVITY 4331. LAB: Output values in a list below a user defined amount -functions 0/10
Computers and Technology
1 answer:
dalvyx [7]3 years ago
4 0

Answer:

The program is as follows:

def output_ints_less_than_or_equal_to_threshold(user_values, upper_threshold):

   for i in user_values:

       if i <= upper_threshold:

           print(i,end=" ")

           

def get_user_values():

   user_values = []

   n = int(input())

   for i in range(n):

       num = int(input())

       user_values.append(num)

   

   upper_threshold = int(input())

   output_ints_less_than_or_equal_to_threshold(user_values, upper_threshold)

get_user_values()

Explanation:

This defines the output_ints_less_than_or_equal_to_threshold method

def output_ints_less_than_or_equal_to_threshold(user_values, upper_threshold):

This iterates through user_values

   for i in user_values:

For every item in user_values

       if i <= upper_threshold:

This prints all items less than or equal to the upper threshold

           print(i,end=" ")

           

This defines get_user_values method

def get_user_values():

This creates an empty list

   user_values = []

This gets the number of inputs

   n = int(input())

This iterates through n

   for i in range(n):

This gets input for every item of the list

       num = int(input())

This appends the input to the list

       user_values.append(num)

This gets input for upper threshold    

   upper_threshold = int(input())

This calls output_ints_less_than_or_equal_to_threshold method

   output_ints_less_than_or_equal_to_threshold(user_values, upper_threshold)

The main begins here; This calls get_user_values method

get_user_values()

You might be interested in
When you started the vi editor, you forgot to specify the name for the new file you are creating. To save steps next time, how c
zysi [14]
Vi ‘filename’
For example file called main.py
vi main.py
8 0
3 years ago
Define 'formatting'<br>​
Fiesta28 [93]

Answer:

Formatting refers to the appearance or presentation of your essay.

Explanation:

Most essays contain at least four different kinds of text: headings, ordinary paragraphs, quotations and bibliographic references.

8 0
3 years ago
Read 2 more answers
Ron is creating building blocks in Word. How can he make the building blocks that he created available?
Gre4nikov [31]

Answer: store those building blocks in the Normal template

Explanation:

Since Ron is creating building blocks in Word, he can make the building blocks that he created available by storing those building blocks in the normal template.

It should be noted that building blocks include lists, tables, text boxes or other contents that an individual uses for his or her word document.

So as to make them readily available whenever they're needed, it is important that they should be stored in the normal template. It will allow for easy access.

3 0
3 years ago
Read 2 more answers
Probablilty can use to determine the likehood of specific_________​
maria [59]

the answer is occurrences

6 0
3 years ago
Read 2 more answers
Companies use virtualization to do all of the following except:
dangina [55]

Answer:

c)

Explanation:

Virtualization refers to running a virtual instance of a computer system apart from the actual software. Companies use this virtualization to do all of the following except Reduce the amount of applications in corporate datacenters. Instead few systems have the applications and those systems are cloned through virtualization.

4 0
3 years ago
Other questions:
  • Which description best describes how mass spectroscopy is useful in the field of forensic toxicology
    6·1 answer
  • A user is trying to delete a file located on an NTFS volume on his Windows 8 computer but is unable to do so. Why is this?
    6·1 answer
  • When the word “computer” was coined, what did it mean?
    12·1 answer
  • What command launches the remote desktop client for windows?
    12·1 answer
  • FREE POINTS JUST ANSWER MY LATEST TWO QUESTIONS PLEASE
    10·2 answers
  • Define the following concepts: computer network, network architecture, protocol, and multilayer protocol.
    11·1 answer
  • The larger the Word Size of a computer
    6·1 answer
  • Which of the following allows computers to communicate with each other? RAM NIC Hard drive Floppy disk
    11·1 answer
  • What is the role of UPS in Computer security?<br>4 marks answer​
    12·1 answer
  • A student wrote a song. Another student posted a video of the song on You Tube, claiming to have written the song. This is most
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!