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
Google's stated mission is to: establish itself as the most valuable media company in the world. organize the world's informatio
pickupchik [31]

Answer:

Yes this is true.

Explanation:

7 0
3 years ago
<img src="https://tex.z-dn.net/?f=%5Cmathcal%7B%5Cfcolorbox%7Bblue%7D%7Byellow%7D%7B%5Cred%7BQUESTIONS%3A%7D%7D%7D" id="TexFormu
Paraphin [41]

Answer:

1. A computer network is a set of computers sharing resources located on or provided by network nodes. The computers use common communication protocols over digital interconnections to communicate with each other.

2. A computer network comprises two or more computers that are connected—either by cables (wired) or WiFi (wireless)—with the purpose of transmitting, exchanging, or sharing data and resources

3. LANs are only designed to connect devices. ... In comparison, WANs can connect all of these same devices as well as LANs. In other words, a WAN can connect multiple LANs together so that all of their respective devices can communicate with each other. WANs are also more difficult to set up and maintain than LANs

Explanation:

hope this helps u

4 0
3 years ago
Read 2 more answers
20.
Kazeer [188]

Answer:

Megabyte

Explanation:

Megabytes come before Gigabytes like how Gigabytes come before Terrabytes

8 0
3 years ago
What file format is best to give a printer when working with Adobe InDesign?
qwelly [4]

Answer:

TIFF

Explanation:

GIFs are animated image files, and printers can't print animations

TIFFs are basically image files

HTML is a coding file, you were to print it, it would print the HTML text of the image

IDML is an XML representation of an InDesign document or components, if you were to print it, its outcome would be basically the same as printing an HTML file.

7 0
3 years ago
Debug the following program.
mamaluj [8]

Answer:

The debugged program is as follows:

A=2

B=2

For I=1 to 10

PRINT A

TEMP = A

A=B

B=TEMP+A

NEXT I

END

Explanation:

First, the value of B should be changed to 4 (because the second term of the sequence is 2

Next, change Display to Print because Q-basic uses the print keyword to display output

The sequence is not properly generated. So, I update that part of the program to:

<em>For I=1 to 10 </em>

<em>PRINT A </em>

<em>TEMP = A </em>

<em>A=B </em>

<em>B=TEMP+A </em>

<em>NEXT I </em>

<em />

Lastly, the loop is controlled by variable I (not X).

So change NEXT X to NEXT I

4 0
3 years ago
Other questions:
  • Machine language is made up of which following codes
    11·1 answer
  • What are some causes of the number of bytes on the wire exceeding the number of bytes being captured?
    6·2 answers
  • Use both if and else may contain only one statement, you would have to use a ______ if you want to use more than one instruction
    14·1 answer
  • Which allows for saving a setting on one device and having the setting synchronize to other devices? Choose two answers.
    12·1 answer
  • Write the definition of a class Clock. The class has no constructors and three instance variables. One is of type int called hou
    12·1 answer
  • A ________ is a single media file including art, sound, animation, or movies.
    9·1 answer
  • Give two advantages of representing integers in pure binary.
    5·1 answer
  • Describe a game that you have played (video game or other type of game) that had a good balance between being easy to learn the
    6·1 answer
  • 5. Why do we need programming language?​
    13·2 answers
  • Explain briefly how learning how to follow can make a person a good leader
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!