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
Tips for being confident and entertaining when presenting?
Mkey [24]
Okay, before you go on, do some power poses. standing with your arms up or your legs spread for like 10 minutes can greatly improve your mood. if you're in a classroom though, and can't do that, I would recommend making sure you have good posture while waiting to go up, and keep a smile on your face the whole time! even long before you start. smiling can increase your happiness a whole lot, so make sure you do it! also before the presentation, make sure you drink plenty of water (a gallon a day for the average adult) and get enough sleep. when preparing for your presentation, don't try to memorize the words you're going to say, (especially not if you'll have a reference like a paper or a slideshow) but memorize the ideas you want to convey. if you've written a speech, don't practice the speech exactly, practice conveying the ideas in it without reading from it. The worst thing you can do during a presentation is just stand there and read. Make sure you make eye contact and don't speak in monotone, tell a story with your presentation, don't just give information. if you need help being confident, I would suggest listening to some of your favourite music or some inspiring speeches (which you can find real easy on google<span>) to make you feel good about yourself. If you are having troubles with stage fright, or being in front of people, the best thing I've ever done, is just pretend they aren't there. Pretend you're just talking to yourself in your bedroom, and it becomes a lot more easy to express yourself. and if none of that sort of stuff works, maybe take some nerve medicine, if you have it. </span>
3 0
3 years ago
Someone who participates online for social reasons usually has a:
Gwar [14]

I would say A.Informal and casual online persona

7 0
3 years ago
If String str = "Computer Science";, then what is the value of str.substring(10);? ​
Genrish500 [490]

Answer:

cience

Explanation:

From the question, the string variable str was initialized to "Computer Science:

str.substring(10) implies that we get a substring starting from the character at the 10th index till the last index

In this case, the 10th index character is c

So, the instruction will return cience

3 0
3 years ago
What is Stefen Salvators mom name? For the tvd fans
jekas [21]

Answer:

Lillian "Lily" Salvatore

Explanation:

8 0
2 years ago
Read 2 more answers
What is GIGO ?<br>plz answer me​
DanielleElmas [232]

Answer:

Garbage in, garbage out

Explanation:

In computer science, garbage in, garbage out is the concept that flawed, or nonsense input data produces nonsense output or garbage

4 0
2 years ago
Other questions:
  • ________ is the abbreviation for the place in the computer where the programs and data the computer is currently using are store
    8·1 answer
  • What are two types of formulas in Excel
    13·2 answers
  • Write a function stats that takes an array and the number of elements in the array. Then, it computes and prints the minimum val
    8·1 answer
  • What makes these Pokémon special?
    9·2 answers
  • Write a Java program called Decision that includes a while loop to prompt the user to enter 5 marks using the
    12·1 answer
  • What should be entered to make the loop print
    6·1 answer
  • What is connectivity?
    15·2 answers
  • Project stem test 3 answers
    14·1 answer
  • "code is broken down by the computer until it is in _____and is a very long series of ons and offs
    11·2 answers
  • I need the answer asap !!!!
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!