<jupyter_start><jupyter_text>Conditions This notion is one of the most important in programming. It introduces logic and allows to create algorithmsThe idea is to express this: ````- If the variable is equal to something then do this.    - Do an action- If not, do this.    - Do an action ```` Python uses boolean variables to evaluate conditions. The boolean values True and False are returned when an expression is compared or evaluated. For example:<jupyter_code>x = 2
print(x == 2) # prints out True
print(x == 3) # prints out False
print(x < 3) # prints out True<jupyter_output>True
False
True<jupyter_text>Notice that variable assignment is done using a single equal operator "=", whereas comparison between two variables is done using the double equals operator "==". The "not equals" operator is marked as "!=". Python uses indentation to define code blocks, instead of brackets. The standard Python indentation is 4 spaces, although tabs and any other space size will work, as long as it is consistent. Notice that code blocks do not need any termination.Here is an example for using Python's "if" statement using code blocks: **if**<jupyter_code>age = 23
if age >= 18:
    print("You're an adult!")<jupyter_output><empty_output><jupyter_text>**elif**  contraction of words "else if"<jupyter_code>age = 17
if age >= 18:
    print("You're an adult!")
elif age == 17 :
    print("You are one year short of being an adult")<jupyter_output><empty_output><jupyter_text>**else**  It is possible to give instructions whatever the possible choices with the keyword "else".<jupyter_code>age = 16
if age >= 18:
    print("You're an adult!")
elif age == 17:
    print("You are one year short of being an adult")
else:
    print("Come back later")<jupyter_output><empty_output><jupyter_text>Logical operatorsLogical operators in Python that are used for conditional statements are true or false. Logical operators in Python are AND, OR and NOT. For logical operators following condition are applied. The "and" and "or" boolean operators allow building complex boolean expressions, for example: **Operator and**<jupyter_code>student1 = "John"
student2 = "Eric"

if student1 == "John" and student2 == "Eric":
    print("You are John AND Eric")   
else :
    print("Welcome anonymous")<jupyter_output><empty_output><jupyter_text>**Operator or**<jupyter_code>student1 = "John"
student2 = "Ludovic"

if student1 == "John" or student2 == "Eric":
    print("Your name is either John or Eric.")
else :
    print("Welcome anonymous")<jupyter_output><empty_output><jupyter_text>The "in" operatorThe "in" operator could be used to check if a specified object exists within an iterable object container, such as a list:<jupyter_code>name = "Valérian"
coach = ["Valérian", "Ludovic"]
if name in coach:
    print("Your are Coach!")
else :
    print("You are not coach")<jupyter_output><empty_output><jupyter_text>The "not" operatorUsing "not" before a boolean expression inverts it:<jupyter_code>print(not False) # Prints out True
print((not False) == (False)) # Prints out False
name = "Ayaan"
if name not in ["Valérian", "Ludovic"]:
    print("Your are not coach")
else :
    print("You are coach")<jupyter_output><empty_output><jupyter_text>The 'is' operatorUnlike the double equals operator "==", the "is" operator does not match the values of the variables, but the instances themselves. For example:<jupyter_code>x = [1,2,3]
y = [1,2,3]
print(x == y) # Prints out True
print(x is y) # Prints out False<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup