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 limits of hashing and verifying that files haven’t changed?
earnstyle [38]

The hashing function can take any number of key-value pairs and there is no specific limit to it.

<h3>What is hashing?</h3>

Hashing is a file-based algorithm for producing a fixed-length bit string value. A file is essentially a collection of data blocks. The length of the data is reduced by hashing to a fixed number or key that represents the original string.

When hashing is employed, the hash function may plot all of the keys and values to what the real size of the table is, demonstrating that the hashing function can take any number of key-value pairs with no restriction.

However, if the passwords are hashed in encryption, recovering the passwords is extremely difficult.

Thus, the hashing function can take any number of key-value pairs and there is no specific limit to it.

Learn more about the hashing here:

brainly.com/question/13106914

#SPJ1

5 0
1 year ago
What will be the results from running the following code?
kari74 [83]

Answer:syntax error

Explanation:

Correct on edg 2021

4 0
2 years ago
In summary, McKibben argues that the inhabitable planet is shrinking because (select all that apply):
Artist 52 [7]

MCKibben argues that the inhabitable planet is shrinking because:

  • Consistently higher temperatures will likely make certain areas uninhabitable
  • Desertification will reduce the amount of harvestable land
  • Coastlines are being lost to sea level rise.

<h3>What is Shrinking?</h3>

This is the process in which an object or place becomes smaller as a result of various activities.

The most suitable options which explains why the planet is shrinking is as a result of a reduction in the areas in which humans can live as a result of the factors mentioned above.

Read more about Planet here brainly.com/question/11157969

7 0
2 years ago
What is the approximate time and death in Sherlock Holmes
kati45 [8]

Answer: 8:58.5204 o'clock a.m

:)

3 0
2 years ago
Read 2 more answers
A 5-inch, f/10 telescope has a 2-inch eyepiece focal. Its magnifying power is: (PLEASE HELP)
tatiyna
The answer is a lol i just looked it up                       







5 0
3 years ago
Other questions:
  • Which of the following typically have the highest auto insurance premiums?
    14·1 answer
  • Driving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon (both doubles) as input, and output the g
    7·2 answers
  • ____ is a practice where a user in enticed by possible rewards and then asked to provide personal information.
    14·1 answer
  • Help me match these answers
    5·1 answer
  • Narrow margins are helpful for which task?
    6·1 answer
  • Write two cin statements to get input values into birthMonth and birthYear. Then write a statement to output the month, a dash,
    7·1 answer
  • To obtain the desired speedup, make sure your new function recursively calls itself no more than once in the body of the method.
    8·1 answer
  • Please help me willgive u brainliest​
    14·1 answer
  • Plzzz help i need this today :(
    15·1 answer
  • Database queries is an example of
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!