Respuesta :
Answer:
- numList = []
- length = int(input("Enter a number: "))
- numList.append(length)
- for i in range(0, length):
- num = int(input("Enter a number: "))
- numList.append(num)
- lowerBound = int(input("Enter a number: "))
- numList.append(lowerBound)
- upperBound = int(input("Enter a number: "))
- numList.append(upperBound)
- output = ""
- for i in range(1, len(numList) - 2):
- if(numList[i] >= lowerBound and numList[i] <= upperBound):
- output += str(numList[i]) + " "
- print(output)
Explanation:
The solution is written in Python 3.
Firstly create a list to hold a list of input (Line 1).
Prompt user to enter the number of desired integer and add it to the numList (Line 3- 4).
Create a for-loop that loop for length times and prompt user to enter a number and add it to numList repeatedly (Line 6 -8).
Next, prompt user to input lowerBound and upperBound and add them as the last two elements of the list (Line 10 - 14).
Create an output string (Line 16) and create another for loop to traverse through the numList from second element to third last elements (Line 18). if the current value is bigger to lowerBound and smaller than upperBound then add the current value to the output string.
At last, print the output string (Line 22).
The program is an illustration of loops.
Loops are used to perform repetitive operations.
The program in Python, where comments are used to explain each line is as follows:
#This defines an empty list
numList = []
#This gets the length of input, and appends it to the list
n1 = int(input()); numList.append(n1)
#This gets the lower bound, and appends it to the list
n2 = int(input()); numList.append(n2)
#This gets the upper bound, and appends it to the list
n3 = int(input()); numList.append(n3)
#The following iteration gets input for the list
for i in range(n1):
numList.append(int(input()))
#The following iteration prints the inputs that are within the boundary
for i in range(3,len(numList)-1):
if(numList[i] >= n2 and numList[i] <= n3):
print(numList[i],end = " ")
Read more about similar programs at:
https://brainly.com/question/13707877