Conditional Expressions

    Sometimes we want to play game on our phone, if the day is Sunday. Sometimes we order Ice cream online if the day is sunny. Sometimes we go hiking if our we get permission.
    All the above statements are decisions which depends on a condition being met.
    In python programming, we must be able to execute instructions on a condition being met. this is what conditions are for !

if, else and elif in python :

    If else and elif statements are a multi way decisions taken by our program due to certain conditions in our code.

Syntax:

if(con1) :
print ("condition1 is true")
elif(con2) :
print("condition2 is true")
else :
print("Other Condition");
a =22
if(a>9) :
print ("Greater")
else :
print ("Lesser")

Relational  operators : These are used to evaluate conditions inside the if statements.

== : equals
>= : greater than / equals to
<= : less than / equals to , etc..

Logical Operators :  In python logical operators operate on conditional statements.

and : true if both operands are true else false
or : true if one of the operand is true else false
not : inverts true to false and false to true

elif clause :

if (condition1) :
#code
elif (condition2) :
#code
elif (condition3) :
#code
.
.
.
else :
#code
***This ladder will stop once a condition in anif or elif is met
*** There can be any number of elif statements
*** Last else is executed only if all  the conditions inside elif fails.

Programs :

1. #Conditional 

a = 8

# 1. if-elif-else ladder in Python
# if(a<3): 
#     print("The value of a is greater than 3")
# elif(a>13):
#     print("The value of a is greater than 13")
# elif(a>7):
#     print("The value of a is greater than 7")
# elif(a>17):
#     print("The value of a is greater than 17")
# else:
#     print("The value is not greater than 3 or 7")

# 2. Multiple if statements

if(a<3): 
    print("The value of a is greater than 3")

if(a>13):
    print("The value of a is greater than 13")
    
if(a>7):
    print("The value of a is greater than 7")

if(a>17):
    print("The value of a is greater than 17")
else:
    print("The value is not greater than 3 or 7")

print("Done")

2. #If else

age = int(input("Enter your age: "))

if age>18:
    print("Yes")
else:
    print("No")

3. #Logical and Relational Operator

age = int(input("Enter your age: "))

if(age>34 or age<56):
    print("You can work with us")

else:
    print("You cannot work with us")

4. # --in-- and --is--

# a = None
# if (a is None):
#     print("Yes")
# else:
#     print("No")

a = [45, 56, 6]
print(435 in a)

5. # --is-- else

a = 6
if(a==7):
    print("yes")
elif(a>56):
    print("no and yes")
else:
    print("I am optional")