Python program to check if a number is positive, negative or 0

Configurare noua (How To)

Situatie

num = float(input(“Enter a number: “))
if num > 0:
print(“Positive number”)
elif num == 0:
print(“Zero”)
else:
print(“Negative number”)

Solutie

Output 1

Enter a number: 1
Positive number

Output 2

Enter a number: -1
Negative number

Output 3

Enter a number: 0
Zero

Tip solutie

Permanent

Voteaza

(1 din 4 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?