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
Which feature in word automatically corrects typos, minor spelling errors, and capitalization as you type? autocomplete spelling
Fed [463]
I think auto correct.....,
8 0
3 years ago
What is Service Operations in ITIL​
Nostrana [21]

Explanation:

the objective of ITIL service operations is to make sure that IT services are delivered effectively and efficiently. the service operation life cycle stage includes the fulfilling of user requests, resolving service failure fixing problems and also carrying out routine operational tasks

7 0
4 years ago
Which search strategy explores nodes from the initial state as well as the goal state?
Simora [160]
Pretty sure it’s c! I’m not 100% tho sorry if I’m wrong have a nice day:)
5 0
3 years ago
Read 2 more answers
With the range E2:E30 selected, create a new conditional formatting rule that uses a formula to apply yellow fill and bold font
Nana76 [90]

Answer:

Attached are the excel screenshots

3 0
4 years ago
What will happen if Sam goes to the View menu, clicks Toolbars, and then clicks Picture?
elena-s [515]
I think the correct answer from the choices listed above is option C. If Sam goes to the View menu, clicks Toolbars, and then clicks Picture, then the picture toolbar will appear. Hope this answers the question. Have a nice day. Feel free to ask more questions.
4 0
3 years ago
Read 2 more answers
Other questions:
  • Is it save too say that any job you apply for or are eligible for has to have some type of technology?
    6·2 answers
  • Which practice represents the trait of effective communication?
    6·2 answers
  • You are performing a manual WLAN RF site survey in a location that has several long hallways with small offices on both sides. Y
    8·1 answer
  • PLEASE HELP ASAP i will mark brilliant
    12·2 answers
  • You can write as many constructors for a class as you want, as long as they all have different ____ lists.
    8·1 answer
  • An example of movement as a gameplay mechanic includes
    14·2 answers
  • ____________ is a widely accepted international best practices framework for implementing information systems security.
    12·1 answer
  • Two words are a ""reverse pair"" if each is the reverse of the other. Write a program that finds all the reverse pairs in the wo
    12·1 answer
  • The signal(s)that control the direction that data is transferred on its buslines is the _________ signal(s).
    11·1 answer
  • write a program that inserts on the p position of a string read from the keyboard also another string read from the keyboard
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!