<jupyter_start><jupyter_text>VGP 245 ConditionalsYou can check for different conditions and the conditions must return True or False.  Note: 0 and NoneType always return False.*  '>' : greater than*  '<' : less than*  '>=' : greater than or equal*  '<=' : less than or equal*  '==' : equals to*  '!=' : not equals toYou can also check if an element is contained within a collection:* in : checks if the element is in the collection * not in : checks if the element is not in the collectionYou can also combine the checks* or : checks that one or the other condition is satisfied to be true. Same as || in C.* and : checks that both conditions are met same as  Same as && in C.To use check for the condition the statement is as follows:if condition:   codeblockIf you want to use and else if and else:if condition:   codeblockelif condition:   codeblockelse:   codeblockNote: the codeblock does not indicate scope i.e. when a local variable is used inside the codeblock, it's still accessible outside the codeblock.  Only functions, classes, and modules have scope in their codeblocks.<jupyter_code>x = 12
y = 42

if x < y:
    print('x < y: x is {} and y is {}'.format(x, y))

def isprime(n):
    if n <= 1:
        return False
    for x in range(2, n):
        if n % x == 0:
            return False
    else:
        return True

n = 5
if isprime(n):
    print(f'{n} is prime')
else:
    print(f'{n} not prime')<jupyter_output><empty_output><jupyter_text>Ternary operatorIn some languages, you can write something like this var1 = condition ? trueValue : falseValueIn Python, you can do the same thing, but the syntax is different.var1 = trueVlaue if condition else falseValue<jupyter_code>choice = True

print('happy' if choice else 'unhappy')<jupyter_output>happy
{'fraction_non_alphanumeric': 0.08422837761447145, 'fraction_numerical': 0.00791407574901074, 'mean_word_length': 3.7580645161290325, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '641937', 'license': 'MIT', 'n_tokens_mistral': 523, 'n_tokens_neox': 507, 'n_words': 247, 'path': 'Class 2/conditional.ipynb', 'repo_name': 'ikarusx/vgp245', 'size': '1769'}