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
_______________ ________________ have human editors that evaluate, select, and organize websites into a hierarchy of categories.
faust18 [17]

Answer:

wtaf dude?! at least do so on you're own questions! now I lost all of my answers thanks to you bro -_-

Explanation:

6 0
2 years ago
Which statement is true?
Alexeev081 [22]

Answer:

Bjarne Stroustrop published the first reference guide for C++

Explanation:

Bjarne Stroustrop is a computer scientist who created the C++ programming language while working at the AT&T Bell laboratory. He also published the first reference guide for the programming language.

In October 1985, the book, The C++ Programming Language, was published. It describes the c++ programming language and was the only documentation and reference guide for the programming language at the time. Newer editions have since been published.

7 0
3 years ago
Read 2 more answers
A network router connects multiple computers together and allows them to send messages to each other. If two or more computers s
Sedbober [7]

Answer:

C = M0(M1+M2+M3)+M1(M2+M3)+M2M3 is the equation which suits

Explanation:

From the given data we can state that we need to activate only one product i.e 1------>activated 0-------->means inactivated and also only one slot is activated at a time.The resultant will be no data inputs n control bits and 2 to the power n output bits.

8 0
3 years ago
The man-in-the-middle attack<br> means what
Tom [10]

Answer:

<em> where the attacker secretly relays and possibly alters the communications between two parties who believe that they are directly communicating with each other.</em>

Explanation:

4 0
3 years ago
Which framework can be used to develop cross-platform applications?
k0ka [10]

Answer:

Qt framework

Explanation:

3 0
3 years ago
Other questions:
  • What is the one common feature that ties together different social media technologies? All of the social media tools we use toda
    5·2 answers
  • Whereas lines of competition are clearly defined in the more established industries, in the Internet industry they are blurred a
    9·1 answer
  • Lydia used software and numerical data to create bar graphs. What software did she use?
    8·2 answers
  • What is one problem you should keep in mind when researching information on the Internet?
    6·2 answers
  • Jennifer frequently uses a few programs on her laptop. Where will she find all the frequently used program icons in her computer
    13·1 answer
  • An ethernet switch has a ____ table which is updated by ______.
    14·1 answer
  • Web 2.0 has led to a shift just from consuming content towards what
    6·1 answer
  • If you filmed a clip in 120fps, how many frames are in a seconds of video.
    13·1 answer
  • Clicking the ____ opens the insert function dialog box.
    13·1 answer
  • Write an algorithm to display your name 10 times​
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!