Theory of Intelligence
11TH•Computer Science•Python Programming•Question 5

Solution

Write a Python program that takes a number as input and checks whether it is positive, negative, or zero using an if-elif-else statement.

Solution

PYTHON
number = float(input("Enter a number: "))
if number > 0:
    print("The number is positive")
elif number < 0:
    print("The number is negative")
else:
    print("The number is zero")

The program takes a number as input. The if-elif-else statement checks three conditions: greater than zero, less than zero, or neither (zero), and prints the matching message.

Discuss theoretical concepts, mathematical formulas, and architectural foundations.

Supports inline code with `backticks`
No comments yet. Be the first to start the discussion!