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]
2 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]2 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
A program written in a(n) procedural language consists of sequences of statements that manipulate data items. __________________
Alenkasestr [34]

Answer:

true.

Explanation:

According to my research on information technology, I can say that based on the information provided within the question the statement is completely true. Procedural programming is a widely used paradigm that basically gives the program a set of routines or specifications, and the program mixes and matches them as they continuously repeat the process. It is used in many areas, including video game development.

I hope this answered your question. If you have any more questions feel free to ask away at Brainly.

7 0
3 years ago
In the context of the box model, what is the difference between a margin and padding
Andrej [43]

Answer:

It is good to know about the differences between margin and padding .Margin is the outer space of an element, while padding is the inner space of an element. In other words, margin is the space outside of an element's border, while padding is the space inside of its border. You can set auto value to margin.

3 0
3 years ago
The factorial of n is equal to ______.
alexdok [17]

Answer:

n! = n*(n-1)*(n-2)*(n-3)* ... *2*1

Explanation:

The factorial operator is simply a mathematical expression of the product of a stated integer and all integers below that number down to 1.  Consider these following examples:

4! = 4 * 3 * 2 * 1

4! = 12 * 2 * 1

4! = 24

6! = 6 * 5 * 4 * 3 * 2 * 1

6! = 30 * 4 * 3 * 2 * 1

6! = 120 * 3 * 2 * 1

6! = 360 * 2 * 1

6! = 720

So, the factorial of n would follow the same as such:

n! = n * (n-1) * (n-2) * ... * 2 * 1

Cheers.

5 0
2 years ago
____ is a style of programming that focuses on the step-by-step sequence of instructions and operations.
mario62 [17]

Answer: Algorithm

Explanation: An algorithm is a plan, a set of step-by-step instructions to solve a problem. it involves three basic building blocks to use when designing algorithms. these are.,

1. Sequencing

2. Selection

3. Iteration

7 0
3 years ago
Read 2 more answers
)In a vector implementation of a stack ADT, you add an entry to the top of a stack using which vector method?
kotykmax [81]

Answer:

B.add.

Explanation:

boolean add(element)

The add method in java inserts an element in the vector.It's return type is Boolean it returns true if the element is successfully inserted in the vector and false if the operation is unsuccessful.There is no Push operation in vector.Hence we conclude that the answer is add.

8 0
3 years ago
Other questions:
  • You should hand write your references on your resume.
    15·2 answers
  • This program has some errors in it that are needed to be checked import java.io.*;
    13·1 answer
  • How many possible keys does the playfair cipher have? an approximate power of 2
    14·1 answer
  • A ________ is a member function that is automatically called when a class object is
    6·1 answer
  • Would anyone know this
    10·2 answers
  • Before measuring resistance of a component, be sure:
    8·1 answer
  • 1. Name the first PC virus.<br> 2. In which language are viruses written for Microsoft programs?
    8·2 answers
  • A Consider the following method definition. The method printAllCharacters is intended to print out every character in str, start
    11·1 answer
  • Margie has found a stock template to use. She changes a few things about the formatting and then saves the
    7·2 answers
  • Basic computer programs used by a variety of companies include:
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!