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 are the real-life applications of coding?
oksian1 [2.3K]

Some example's of coding affecting real life:

  • Traffic Lights
  • Biometric Security
  • Robots used in factories. can work in extreme conditions.
  • Automatic Heater or Air Conditioner.
  • Expert Systems used in for Medical Use.
  • Smart Self Driving Cars
8 0
2 years ago
Linux distributions overview? information​
disa [49]

Answer:

Debian

Arch Linux

Ubuntu

Fedora

Manjaro

Linux Mint

Elementary OS

openSUSE

Explanation:

6 0
3 years ago
What does gps stand for ?
frutty [35]
GPS stands for Global Positioning System
3 0
3 years ago
Read 2 more answers
A major retailer wants to enhance their customer experience and reduce losses
Mrac [35]

Answer:

Predict Demand

Explanation:

The type of Artificial Intelligence (Al) solution that would be suitable for solving this problem is "Predict Deman"

By predicting the demand of the potential consumer through the Artificial intelligence solution the retailer would be able to eliminate leftover out-of-stock scenarios because the adequate quantity of the products or demands will be provided thereby enhancing customers' experience arising from out-of-stock scenarios and reducing losses arising from the leftover.

5 0
3 years ago
True or false for a given set of input values, a nand
Katen [24]
Nand stands for "not and". The truth table for a nand is:

a b | a nand b
0 0 |      1
0 1 |      1
1 0 |      1
1 1 |      0

Hopefully this helps you answer your question.
6 0
3 years ago
Other questions:
  • Liz will use a CD-R compact disk to write to more than once. Carlo will use a CD-RW compact disk to write to more than once. Who
    8·2 answers
  • Your brother is starting 9th grade next year and is thinking about going to college. What step would you recommend he take?
    14·1 answer
  • Southern States<br> Wanted...<br> But...<br> So...
    12·1 answer
  • Ead the following scenario and then answer the question.
    10·1 answer
  • Question 1 (1 point)
    10·2 answers
  • You make an online purchase of a hooded sweatshirt with the logo of the Dallas Cowboys. The next time you log on, your screen ha
    13·1 answer
  • Given that Apache and Internet Information Services (IIS) are the two most popular web application servers for Linux and Microso
    10·1 answer
  • Can someone please help me I need to turn this in my 3:00pm Eastern time
    12·1 answer
  • Which user interface part shows graphical output of mined data?
    8·2 answers
  • Imagine that you just received a summer job working for a computer repair shop one of your first task is to take apart a compute
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!