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
Name at least TWO kinds of gaming experiences that are possible with these new control devices but were not possible on original
Pie

Yes the ansewer is c bc you can look it up!


6 0
3 years ago
Which would be the most efficient way to store files on your computer?
lorasvet [3.4K]

Answer:

Best way to store all your files is a external storage device, like a hard drive or a usb stick, copy all your files to the device and keep it in a safe place.

3 0
3 years ago
What is the recommended point size for a slide title?<br> 12–22<br> 24–40<br> 44–66<br> 54–80
jenyasd209 [6]
12-22 hope this helps :)
3 0
3 years ago
What would be the best thing you could do to prepare yourself to work for a company that has embraced globalization?
kvasek [131]
Learn a foreign language
4 0
3 years ago
How come the scroll bar on the PA emojis only appears sometimes? how do I make it appear?
astraxan [27]
Answer it your own self everybody can't always give u the answers
5 0
3 years ago
Other questions:
  • Which statement is true about parity in RAM?
    11·1 answer
  • What is the function of the keyboard shortcut Ctrl+Shift+E in a word processor
    5·2 answers
  • Which two software interfaces allow adjustment of the cpu voltage? (choose two.)?
    10·1 answer
  • Determine if the following statement is true or false:
    5·2 answers
  • A program that will read each player’s name and golf score as keyboard input,
    9·1 answer
  • The memory used by the CPU to temporarily hold data while processing is called _______. random access memory central processing
    5·1 answer
  • Which tags do you use to write the header and items of an ordered list on a web page?
    14·1 answer
  • In how many positions are there nucleotide differences between your query sequence and the sequence of accession AY259214.1
    12·1 answer
  • Big Data _______________. Relies on the use of unstructured data imposes a structure on data when it is captured relies on the u
    15·1 answer
  • before you start researching fleet management software, your first task is to clearly define the problem. this will help guide y
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!