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
Which of the following statements best compares and contrasts the role of story writers and script writers
Citrus2011 [14]

Answer:

Both script and story writers must use the elements of plot to develop their work; however, script writers must also include the use of stage and camera descriptions.

Explanation:

7 0
2 years ago
Robert needs to apply formatting from one set of text to multiple other sets of text throughout the document. Which option shoul
stiks02 [169]

Answer:

I think the answer is option D (double-click Format Painter)

Explanation:

7 0
2 years ago
What is cyber safety?
mario62 [17]

Answer: Cyber safety is a process that protects computers and networks. The cyber world is a dangerous place without security and protection.

Explanation: Hope this helps!

7 0
3 years ago
What is Game Theory?
AleksandrR [38]

Answer:

the branch of mathematics concerned with the analysis of strategies for dealing with competitive situations where the outcome of a participant's choice of action depends critically on the actions of other participants

Explanation:

In simple terms Game theory is the study of how and why people make decisions.

8 0
2 years ago
If every element of a list must beprocessed, a(n) __________is more efficient than a(n)______.
statuscvo [17]

Answer:

B - array; hash

Explanation:

Arrays store elements of the same data type in a list. Every element in the array is assigned a unique integer (starting at 0). You are able to access/process an element by using its assigned integer. Hashes are similar in the fact that they also store data. The difference is that each element is assigned an object type (instead of an integer), making it a collection of key pairs, as such you would typically not use this to process elements efficiently.

6 0
3 years ago
Other questions:
  • What is the other name of the horizontal column graph?
    6·2 answers
  • What will be the value of i after the C statements at the right have been executed
    6·1 answer
  • In the accompanying figure, the split double arrow mouse pointer____.
    7·1 answer
  • Translate the following C++ program to MIPS assembly program. *Please explain each instruction of your code by a comment and sub
    5·1 answer
  • Which type of styles can be applied to a word, phrase, or sentence?
    7·1 answer
  • Who is hurt by piracy
    10·1 answer
  • Harrison works in a manufacturing unit and oversees the logistics, including the daily shipping of a large number of packages. W
    12·2 answers
  • A program that allows employees to choose their starting and ending times, as long as they are at work during a specified core p
    8·1 answer
  • Which software manages the functioning of the entire computer system<br>​
    7·2 answers
  • Besides a backup technician, who else would have encrypted backup passwords?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!