## basic if True: print('Conditional was true') # Conditional was true if False: print('Conditional was true') # # Comparisons # Equal: == # Not Equal: != # Greater Than: > # Less Than: < # Greater or Equal: >= # Less or Equal: <= # Object Identity: is language = 'Python' if language == 'Python': print('Conditional was true') # Conditional was true else: print('No match') num = [1,2,3] num_two = [1,2,3] num_three = num print(num is num_two) # False print(num is num_three) # True print(id(num)) print(id(num_two)) # if elif else language = 'Python' if language == 'Python': print('Conditional was true') elif language == 'Java': print('Language is Java') else: print('No match')
# booleans operators: and or not user = 'Admin' logged_in = True if user == 'Admin' and logged_in: print('Admin Page') else: print('Bad') if user == 'Admin' or logged_in: print('Admin Page') else: print('Bad') if not logged_in: print('Please Log in') else: print('Welcome') # False Values: # False # None # 0 of any numeric type # Any empty sequence, for example: '', (), [] # Any empty mapping, for example: {} condition = False if condition: print('Evaluated to True') else: print('Evaluated to False')