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
Lapatulllka [165]
4 years ago
8

Wrtie a program in which we will pass a value N. N can be positive or negative. If N is positive then output all values from N d

own to and excluding 0. If N is negative, then output every value from N up to and excluding 0.
Computers and Technology
1 answer:
Triss [41]4 years ago
5 0

Answer:

Following are the answer to this question:

x=int(input("Enter number: "))#defining x variable that input value from user end

if x< 0:#defining if block that check x value is less then 0

   while x<0:#defining while loop print up to the value

       print(x)#print value

       x+= 1#add values by 1

elif x>0:#defining elif block to check value x is greater than 0

   while x>0:#defining while loop to print down to value

       print(x)#print value

       x-= 1#subtract value by 1

Output:

when input is a positive value

Enter number: 5

5

4

3

2

1

when input is a negative value

Enter number: -5

-5

-4

-3

-2

-1

Explanation:

  • In the given python code, x variable is declared that input the value from the user end, in the next step if and elseif block is declared that calculates and prints its value.
  • In the if block, it checks value is negative it uses the while loop to prints its values in the down to value form.
  • In the elif block, it checks the positive it uses the while loop to prints its values into the up to values form.  
You might be interested in
Give two examples of situations or applications where electrical circuits are used.
Pavlova-9 [17]

Answer:

lamps, electric motors

Explanation:

5 0
3 years ago
What is an example of a reference marker that a source might use? quotation print Web page numbering
olya-2409 [2.1K]

Answer

page numbering

Explanation

Page numbering is where the writer employs a process of applying sequence of numbers to pages of a certain document may it be a book, a magazine, a news paper or any other document having pages.The reference marker that a source might use a page numbering  to be able to reference details that are referenced in other details. By this it reduces complication

3 0
3 years ago
Read 2 more answers
Bloxburg Build can anyone help me
postnew [5]
Om I would love to helpppp friend me- keabbykelp
5 0
3 years ago
Read 2 more answers
A derived class has access to __________.
Kitty [74]

Answer:

Option a is the correct answer for the above question

Explanation:

The derived class is a class that inherits the property of the base class, and he can access the public variable and function or members of the base class or ancestor class.

Option 'a' also states the same and the question asked about the assessment of the derived class. Hence option a is the correct answer while the other is not because:-

  • Option b states about the private members, but it is not accessible by the derived class.
  • Option c states about the derived class members but it can also access the base class members.
  • Option d none of the above, but option a is the correct answer.

5 0
4 years ago
Create a program called "Geometry" Prompt the user for a small decimal number. Prompt the user for a large decimal number. Using
skelet666 [1.2K]

Answer:

In Python:

import random

small = float(input("Small: "))

large = float(input("Large: "))

radius = round(random.uniform(small, large),2)

volume = round(4/3 * 22/7 * radius* radius* radius,2)

print("Radius: "+str(radius))

print("Volume: "+str(volume))

Explanation:

This imports the random module

import random

The next two lunes prompt the user for small and large decimal number

small = float(input("Small: "))

large = float(input("Large: "))

This generates the radius

radius = round(random.uniform(small, large),2)

This calculates the volume

volume = round(4/3 * 22/7 * radius* radius* radius,2)

This prints the generated radius

print("Radius: "+str(radius))

This prints the calculated volume

print("Volume: "+str(volume))

<em>Note that, the radius and the volume were approximated to 2 decimal places. Though, it wasn't stated as part of the program requirement; but it is a good practice.</em>

8 0
3 years ago
Other questions:
  • The main differences between laptops and desktop computers other than size and portability.
    14·1 answer
  • Is it true or false for this question?
    8·1 answer
  • Sending packets with false ip source addresses is called ____. ip address spoofing a port scanning attack a ip address scanning
    11·1 answer
  • When you want to specify multiple criteria, and all criteria must be true for a record to be included in the results, when the _
    9·1 answer
  • An I/O-bound process ___________________________________________________ Select one: a. does not need CPU time b. spends less of
    14·1 answer
  • Steve adds a second 1-GB 240-pin DIMM to his PC, which should bring the total RAM in the system up to 2 GB. The PC has an Intel
    14·1 answer
  • int myArray-11,3,-8,30,-2,0,5,7,-100,44); Write a loop statement to display the positive numbers each on a separate line like th
    6·1 answer
  • Why did Herman Hollerith invent the Tabulating Machine?
    10·1 answer
  • Assume the existence of a BankAccount class with a constructor that accepts two parameters: a string for the account holder's na
    14·1 answer
  • Before entering an intersection, the safest searching process is to search ________. right, left, right, center left, center, ri
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!