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]
3 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]3 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
What makes the huns a formidable force for the roman empire?
Maurinko [17]
<span>The Huns were a formidable force to fight. They were able to eat most food without problem which removes the needs for supply trains and such and encourages pillaging. Another reason is that their a cavalry based army which completely decimated roman military since the roman empire consist of flat land and they could outflank, outrun, and could whittle down an army with ease. They also are nomads which means you don't know where they're living and so you can't be on the attack which also gave an advantage. This points that the Huns are a force to be reckon with.</span>
7 0
3 years ago
Complete the paragraph to explain how Angelina can notify readers that her report is just a draft.
iogann1982 [59]

Answer:

Background

Design

Page background

Custom

Explanation:

5 0
3 years ago
Every command or instruction is called
Elza [17]

Answer:

statement........................

6 0
3 years ago
Read 2 more answers
For your biology class, you have taken a number of measurements for a plant growth experiment. You wish to create a chart that s
Mamont248 [21]
Calc or excel
Hope this helps
4 0
3 years ago
The 3rd generation programming language that most students learned when most computers used MS DOS was ___ . It remains a safe p
Diano4ka-milaya [45]

Answer:

Basic

Explanation:

The 3rd generation programming language that most students learned when most computers used MS DOS was basic. It remains a safe programming language for using 3rd party code and provides a coding standard that integrates easily with other programming languages.

7 0
3 years ago
Other questions:
  • Cleo finds herself frequently searching for messages from particular senders or with specific subjects. What should she create
    5·1 answer
  • You notice that lately your computer has been running slow. When you open up your web browser, you get endless pop-up ads to the
    8·1 answer
  • Please help
    5·1 answer
  • Which is a benefit of peer-to-peer networking?
    10·1 answer
  • In project integration management, project ______ and _______ are intertwined and inseparable activities
    14·1 answer
  • The_provides access to the internet may also be internal​
    9·1 answer
  • Question 1 (1 point)
    10·2 answers
  • Wireless attacks avoid the access points to limit detection. <br> a. True <br> b. False
    9·1 answer
  • Using the Vigenere cipher, does the length of the key matter?
    8·1 answer
  • Why the internet is not considered a mass medium in Africa​
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!