Computer Science, asked by oindrilla20, 10 months ago

Write a program in Python to print one of the words negative, zero or positive, according to whether variable x is less than zero, equal to zero or greater than zero , respectively.​

Answers

Answered by ShadowDane
11

Answer:

In this example, you will learn to check whether a number entered by the user is positive, negative or zero. This problem is solved using if...elif...else and nested if...else statement.

Explanation:

Source Code: Using if...elif...else

num = float(input("Enter a number: "))

if num > 0:

  print("Positive number")

elif num == 0:

  print("Zero")

else:

  print("Negative number")

Source Code: Using Nested if

num = float(input("Enter a number: "))

if num >= 0:

  if num == 0:

      print("Zero")

  else:

      print("Positive number")

else:

  print("Negative number")

Answered by prakharagrawal6055
2

Answer:

x=float(input("Enter a number:"))

if x==0:

   print("Your number is Zero")

elif x>0:

   print("Your number is greater than Zero")

elif x<0:

   print("Your number is smaller than Zero")

Explanation:

Similar questions