Python Programming

Tutorial No. 3 : Conditional Statements in Python

Conditional Statements
Resources

For Simple if Statement

n = 1
if n > 0:
   print(n, "is a positive number.")
print("This is next statement")
print("***************************")
n = -1
if n > 0:
    print(n, "is a positive number.")
print("This is next statement")

For Simple if else Statement

n = 1
if n > 0:
   print(n, "is a positive number.")
else:
    print(n, "is a negative number.")
print("This is next statement")

For if elif else Statement

n = -1
if n > 0:
    print(n, "is a Positive No.")
elif n < 0:
    print(n, "is a Negative No.")
else:
    print(n,"is a Zero No.")
print("This is next statement")

Multiple if Statement

n = 0
if n >= 0:
    if n==0:
        print(n, "Zero number.")
    else:
        print(n, "is a Positive number.")
else:
     print(n,"is a Negative Number")
print("This is next statement")