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
Why should technology be used. No plagiarism pls.
olga nikolaevna [1]

Answer:

Explanation:

mobile devices and the applications they help us in life devisec can individualize instruction. three specific reasons that technology is good is that it saves lives by improving medicine, keeps us connected to each other, and provides education and entertainment. One reason why technology is good is that it has saved many lives.

3 0
3 years ago
Read 2 more answers
What is hexadecimal number system​
eduard

Our usual number system is the decimal number system. As the name suggests, it uses base 10.

Using a certain base to express numbers means to write numbers as weighted sums of powers of the base. For example, in base 10 we write

1437 = 1\cdot 10^3 + 4\cdot 10^2 + 3\cdot 10^1 + 7\cdot 10^0

So, the weights of the powers are what we call the digits of the number.

Note that our digits finish at 9 because it wouldn't make sense to have a digit to express 10: if we choose a weight of 10 (or more) for a certain power, we can simply scale it to the next one: for example, saying "ten hundreds" is the same as saying "one thousand":

10\cdot 10^2 = 1\cdot 10^3

Now, the hexadecimal number system simply uses 16 as base, instead of 10. This means that its digits are

1,2,3,4,5,6,7,8,9,A,B,C,D,E,F

where digits from A to F represent numbers from 10 to 15.

These are some examples of hexadecimal numbers turned into our usual system:

(47B)_{16} = 4\cdot 16^2+7\cdot 16^1+11\cdot 16^0 = 1024+112+11=(1147)_{10}

(CAF35)_{16} = 12\cdot 16^4+10\cdot 16^3+15\cdot 16^2+3\cdot 16^1+5\cdot 16^0 = 786432+40960+3840+48+5=(831285)_{10}

6 0
3 years ago
Sang ayon kaba sa pahayag na walang sinuman ang nabubuhay para sa sarili lamang? bakit?
d1i1m1o1n [39]
What language is this?
7 0
3 years ago
Silas is planning on configuring various default options in PowerPoint 2016. Which tab will provide him with the ability to modi
Iteru [2.4K]

Answer:

Proofing

Explanation:

C: Proofing

8 0
3 years ago
Read 2 more answers
In HTML, what is an element?
Dima020 [189]

Answer:

An markup language component is a private element of associate degree HTML (Hypertext Markup Language) document or web content. markup language consists of a tree of HTML nodes, like text nodes. Nodes may have content, as well as alternative nodes and text. several markup language nodes represent linguistics, or meaning.

Explanation:

Hope this help!

5 0
3 years ago
Read 2 more answers
Other questions:
  • Why should you limit what information is in your digital footprint?
    12·1 answer
  • Why has unicode become the standard way of converting binary to text
    7·1 answer
  • 1. Create a detail report that will display all SCR courses in alphabetical order, with the course name and the instructor name
    6·1 answer
  • A characteristic of a 3D model that a 2D model does not have is:
    8·1 answer
  • When using Regedit to browse through the registry, the key that is highlighted is the ________, and its value entries are visibl
    5·1 answer
  • Write a program that replaces words in a sentence. The input begins with an integer indicating the number of word replacement pa
    13·1 answer
  • DOC
    11·1 answer
  • You are hired to train a group of new users to become technicians. One of your lessons is on how to construct Cat5 and Cat6 Ethe
    10·1 answer
  • State the difference between = and ==
    9·1 answer
  • 4. Compute the following additions
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!