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
Write a series of conditional tests. Print a statement describing each test and your prediction for the results of each test. Fo
N76 [4]

Answer:

this:name = 'John'

print("Is name == 'John'? I predict True.")

print(name == 'John')

print("\nIs name == 'Joy'? I predict False.")

print(car == 'Joy')

this:age = '28'

print("Is age == '28'? I predict True.")

print(age == '28')

print("\nIs age == '27'? I predict False.")

print(age == '27')

this:sex = 'Male'

print("Is sex == 'Female'? I predict True.")

print(sex == 'Female')

print("\nIs sex == 'Female'? I predict False.")

print(sex == 'Joy')

this:level = 'College'

print("Is level == 'High School'? I predict True.")

print(level == 'High School')

print("\nIs level == 'College'? I predict False.")

print(age == 'College')

Conditions 1 and 2 test for name and age

Both conditions are true

Hence, true values are returned

Conditions 3 and 4 tests for sex and level

Both conditions are false

Hence, false values are returned.

7 0
3 years ago
An organization is implementing a preselected baseline of security controls, but finds not all of the controls apply. What shoul
WINSTONCH [101]

The answer is Tailoring the baseline to their needs.

After an organization selects applicable security control baseline but finds not all of the controls apply, it initiates a tailoring process to modify the controls appropriately and more closely with specific conditions related to organizational missions, information systems or environments of operation. It is an integral part of the security control selection and specification and involves risk management processes like assessing, responding to, and framing.

8 0
3 years ago
One of the main responsibilities employers have under OSHA is to:
poizon [28]
What dose osha means please
7 0
3 years ago
Read 2 more answers
What is an oxidation state?
vekshin1
Based on the definition which states it is an indicator of oxidation of an atom in a chemical compound. I believe the most viable answer is the charge of an atom's ion.
7 0
3 years ago
BRAINLIEST plz help
avanturin [10]

Answer:C

Explanation:

8 0
3 years ago
Other questions:
  • You are configuring two switches of different vendors such that they connect to each other via a single link that will carry mul
    13·1 answer
  • Your company has recently been hired to install a smart security system for a large office building. The system will include sec
    12·1 answer
  • Jeanne writes a song, and Raul wants to perform
    6·2 answers
  • A hacker uses a valid IP address of an internal host, and then from an external system, the hacker attempts to establish a commu
    11·1 answer
  • How can I make a website login system with only using php?​
    6·1 answer
  • The number of pixels displayed on the screen is known as ________.
    13·1 answer
  • What will the following code print out: int numbers [] = {99, 87, . 66, 55, 101}; for (int i = 1; i &lt; 4; i++) cout &lt;&lt; n
    11·1 answer
  • What is presentation
    15·2 answers
  • Which actions are available in the Trust Center? Check all that apply.
    8·1 answer
  • Need help finding the totals and with the empty spots
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!