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
aleksandr82 [10.1K]
3 years ago
8

8.13 LAB: Elements in a range Write a program that first gets a list of integers from input. That list is followed by two more i

ntegers representing lower and upper bounds of a range. Your program should output all integers from the list that are within that range (inclusive of the bounds). Ex: If the input is: 25 51 0 200 33 0 50 the output is: 25 0 33 The bounds are 0-50, so 51 and 200 are out of range and thus not output. For coding simplicity, follow each output integer by a space, even the last one. Do not end with newline
Computers and Technology
1 answer:
MArishka [77]3 years ago
5 0

Answer:

  1. myList = []
  2. num = int(input("Enter a number: "))
  3. while(num != -1):
  4.    myList.append(num)
  5.    num = int(input("Enter a number: "))
  6. output = ""
  7. for i in range(0, len(myList) - 2):
  8.    lastIndex = len(myList) - 1
  9.    secondLastIndex = len(myList) - 2
  10.    if(myList[i] >= myList[secondLastIndex] and myList[i] <= myList[lastIndex]):
  11.        output += str(myList[i]) + " "
  12. print(output)  

Explanation:

The solution is written in Python 3.

Firstly, create a list to hold the user input of integers.

Next,  use input function to prompt user to enter integer and assign it to num

While the input num is not -1, keep prompting the user to input number and add it to myList (Line 4 - 6)

Create a output string variable (Line 8)

Create a for loop to traverse through the first element to third last of the element because the last two elements are bounds (Line 9).

Get the last and second last index (Line 10 -11)

Create an if statement to check the current element is within the lower bound and upper bound. If so, join the element to output string (Line 12 - 13).

After the loop, print the output string (Line 15).

You might be interested in
Which of the following terms refers to the area of the hard drive used for virtual memory?
Andre45 [30]

Answer: C. Swap File

Explanation: Swap files provide some space for programs for the computer and virtual memory.

8 0
2 years ago
A wide-angle lens corrected for barrel distortion is called a(n)<br> lens.
Sonja [21]

Answer:

Rectilinear lens

Explanation:

In photography, the distortions are caused in the formation of the image due to either the position of the camera or the optical design of the lenses i.e perspective and optical distortion.

The barrel distortion is a type of optical distortion caused due to the optical design of the lens. In barrel distortion, the straight lines of the light bend as a result of which the lines appear curved inwards in images.  

The field of view of wider than the image sensor in barrel distortions which can be corrected by the use of rectilinear lens which provides straight lines without bending them. This lens stretches the image towards the edge and removes distortion.

Thus, Rectilinear lens is the correct answer.

3 0
3 years ago
Class secretType { public: static int count; static int z; secretType(); secretType(int a); void print(); static void incrementY
ANEK [815]

Answer:

a. secretType mySecret(9)

Explanation:

6 0
3 years ago
Unanswered questionl
antoniya [11.8K]

¿ ? ¿ ? Whattttt ? ¿ ? ¿

3 0
3 years ago
Inserting and deleting text is a basic editing task in word processing.<br><br> True or false
Katyanochek1 [597]
The answer should be true
3 0
3 years ago
Read 2 more answers
Other questions:
  • Which of these does an open office or Microsoft Office wizard do?
    7·1 answer
  • What are 3 characteristics of syndrome E?
    13·1 answer
  • If I deal seven cards from a standard deck of 52, what is the chance that I will get two triples (three of a kind) and one other
    11·2 answers
  • Assume that the population of Mexico is 128 million and that the population increases 1.01 percent annually. Assume that the pop
    7·1 answer
  • Why is it important to use a structured cabling standard when installing and managing cabling systems?
    12·1 answer
  • what is the ability to carry out financial transactions using mobile devices such as tablets and phones?
    5·1 answer
  • What are the flowchart symbols?​
    6·1 answer
  • There are two circular grounds Ground-A and Ground-B. Ground-A is having diameter of 15 meters and Ground-B is having diameter o
    7·1 answer
  • Why is one climate different from another?
    14·1 answer
  • Weird canvas submission, I’ve done directly what the directions say to do to submit it, but it won’t submit
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!