53.9k views
1 vote
IN PYTHON

Write a program that first gets a list of integers from input. The input begins with an integer indicating the number of integers that follow. Then, get the last value from the input, and output all integers less than or equal to that value.

1 Answer

2 votes

Answer:

Python program is given below

Step-by-step explanation:

def output_ints_less_than_or_equal_to_threshold(user_values, upper_threshold):

print("The integers that are less than or equal to", upper_threshold, "are:")

for value in user_values:

if value < upper_threshold:

print(value)

def get_user_values():

n = int(input("Enter the number of integers in your list: "))

lst = []

print("Enter the", n, "integers:")

for i in range(n):

lst.append(int(input()))

return lst

if __name__ == '__main__':

userValues = get_user_values()

upperThreshold = int(input("Enter the threshold value: "))

output_ints_less_than_or_equal_to_threshold(userValues, upperThreshold)

User PatPanda
by
7.3k points