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]
2 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]2 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
What is the best application to create a slide show presentation?
Lynna [10]

Answer:

Microsoft Windows File Manager

5 0
3 years ago
Read 2 more answers
When using _____, developers are required to comply with the rules defined in a framework. (Points : 2) inheritance
Nikolay [14]

Answer: Contracts

Explanation:

The contract is the mechanism which is basically used by the developers to follow the set of rules that is defined in the framework with the proper specification in the API ( Application programming interface).

The contract is the proper agreement between the two and more developers so that they must follow the rules that is mentioned in the agreement contract.  

The contract is widely used in the software development process in which all the possible design requirement are mentioned according to the needs of the client.

Therefore, Contract is the correct option.

7 0
3 years ago
In what domain electrica energy is the most use
amm1812

Answer:the main signal bearing entities are voltage and their current in circuit environments.

Explanation:

5 0
3 years ago
What is the main reason for adding somebody into the BCC list for an email?​
Fiesta28 [93]

Answer:

protecting email address privacy

Explanation:

for securing and privacy reasons and it is for the best

6 0
2 years ago
If you type too much text on a PowerPoint slide, the additional text is added to a second slide.
Snowcat [4.5K]

Answer:

This is false

The text just goes out of the slide and you can't see it until you lower the font size or until you delete some of it.

Explanation:

5 0
3 years ago
Other questions:
  • K
    15·2 answers
  • Can someone please help me with the three questions please?
    6·1 answer
  • If you're using the paintbrush tool and want to change the color of the paint being used what should you change
    6·1 answer
  • Which type of graph or chart will you use to show changes in data points?
    5·1 answer
  • Write a program to generate a square wave with 80% duty cycle on bit P2.7 Microprocessor.​
    7·1 answer
  • have you ever had to adjust your communicatio style to egage a customer or roommate? what was the situation and outcome?
    5·1 answer
  • Identify the names of the following:<br><br>Please help me.​
    12·1 answer
  • Suppose a large group of people in a room were all born in the same year. Consider the following three algorithms, which are eac
    8·1 answer
  • Please help
    5·1 answer
  • while determining which antibiotics are best to treat ulcers caused by helicobacter pylori, the drugs used in the experiment are
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!