[Type C]Q1. Write a program to print one of the words negative, zero, or positive, according to whether variable x is less than zero, is zero, or greater than zero respectively.

If-Else syntax:

if (condition):
 statement
elif (condition):
 statement 
else:
 statement

If else flowchart:

if-else-flowchart

Program code:

Clear Doubts with Computer Tutor
In case you’re facing problems in understanding concepts, writing programs, solving questions, want to learn fun facts | tips | tricks or absolutely anything around computer science, feel free to join CTs learner-teacher community: students.computertutor.in

Output:

Enter any number:1
Positive

In the above program, a number is taken as input from a number which is then compared to check if it is zero, positive(>0), or negative(<0). The result is returned on the console using the print function.

Basic python functionality is demonstrated in above program.

To view all the lessons in chapter 1: http://computertutor.in/class-12-computer-science/chapter-1/

To view entire class 12 computer science study material: http://computertutor.in/resources/

You cannot copy content of this page