CBSE Class 11 Computer Science
Question 29 of 39
Conditional and Looping Constructs — Question 29
Back to all questions 29
Question Write a program to check if the number is positive or negative and display an appropriate message.
number = int(input("Enter a number: "))
if number > 0:
print("The number is positive.")
else:
print("The number is negative.")Enter a number: 4
The number is positive.
Enter a number: -6
The number is negative.
number
=
int
(
input
(
"Enter a number: "
))
if
number
>
0
:
print
(
"The number is positive."
)
else
:
print
(
"The number is negative."
)
Output
Enter a number: 4
The number is positive.
Enter a number: -6
The number is negative.