Untitled Document
Conditionals - if , if - else , elif statements
1. Program - Simple (Basic) if else statement Click Here
       #********* Source Code From Website - Mangadaku - visit us at -http://mangadaku.com/ *****      
       # Program - Simple (Basic) if else statement 
       
       # Ex1 - Basic If Else Statement 
       language ='Python'
       if language == 'Python':
       	print("Language is Python")
       else:
       	print("No Match")
       
2. Program - If else with elif statement Click Here
       #********* Source Code From Website - Mangadaku - visit us at -http://mangadaku.com/ *****      
       # Program - If Else with elif statement
       
       language ='Python'
       if language == 'Python':
       	print("Language is Python")
       elif language =='Java':
       	print('Language is Java')
       else:
       	print("No Match")
       
3. Program - If else with ( and , or and not ) operators Click Here
       #********* Source Code From Website - Mangadaku - visit us at -http://mangadaku.com/ *****      
       # Program - If else with ( and , or and not ) operators 
       # Here we will use different conditonal operators to evalautae conditions 
       
       # 1 : and condition 
       # If else with and condition ; here if block will be executed only if both the conditions evaluated to true
       #Ex - 1 :
       
       user = 'Admin'
       logged_in = True
       if user == 'Admin' and logged_in:
       	print('Admin Page')
       else:
       	print('Bad Credentials')
       
       # Ex - 2 :
       
       user = 'Admin'
       logged_in = False
       if user == 'Admin' and logged_in:
       	print('Admin Page')
       else:
       	print('Bad Credentials')
       
       #2 : or condition
       #If else with or condition ; here if block will be executed either of the condition evaluated to true
       # Ex - 1 
       
       user = 'Admin'
       logged_in = False
       if user == 'Admin' or logged_in:
       	print('Admin Page')
       else:
       	print('Bad Credentials')
       
       #3 : not condition 
       # If else with not condition ; here if block will be executed when condition is not True
       
       user = 'Admin'
       logged_in = False
       if not logged_in:
       	print("Please Log in")
       else:
       	print("Welcome")
       
       #4 : is condition 
       # If else with is condition ; this is used for object comparison ; to check whether the two ojects have same id or not .
       
       a= [1, 2, 3]
       b= [1, 2, 3]
       
       print(a==b)
       print(id(a))
       print(id(b))
       
       b=a
       
       print(a is b)
       print(id(a))
       print(id(b))
       
4. Program - What are all scenarios where values / condition will be evaluated to False : Click Here
       #********* Source Code From Website - Mangadaku - visit us at -http://mangadaku.com/ *****      
       # Program - What are all scenarios where values / condition will be evaluated to False : 
       # Here are the values which will always evaluate condition to False 
       
       # 1. False
       # 2. None 
       # 3. Zero of any numeric type
       # 4. Any Empty Sequence . For Example , '', () ,[] ,{}
       
       # Just replace the condition varibale with any of the above and see the results
       
       condition=None     
       if condition:
       	print("Evaluated to True")
       else:
       	print('Evaluated to False')
       
Untitled Document