<jupyter_start><jupyter_text>Beginning Programming in Python Advanced Branching CSE20 - Spring 2021Interactive Slides: [https://tinyurl.com/cse20-spr21-advanced-branching](https://tinyurl.com/cse20-spr21-advanced-branching)  Review: `if` Statement```pythonif [condition]:    note that the line ends with a ':'     code to execute if condition is true     note also this is indented by 4 spaces    print("Looks like '[condition]' was True")```  Review: `if` Statement      Review: `if` Statement<jupyter_code># insurance premium calculator
color = "blue"
max_speed_mph = 80

insurance_premium = 150

if color == "red":
    insurance_premium = insurance_premium + 50
    
if max_speed_mph > 100:
    insurance_premium += 75

print("Total insurance premium: $", insurance_premium)<jupyter_output><empty_output><jupyter_text>Review: `if`/`else` statement```pythonif [condition]:    note that the line ends with a ':'     code to execute if condition is true     note also this is indented by 4 spaces    print("Looks like '[condition]' was True")else:  this line also ends with a ':'    print("Looks like '[condition]' was False")```  Review: `if`/`else` Statement      Review: `if`/`else` Statement<jupyter_code># Shareable pizza calculator
num_slices = 8
num_friends = 4

if num_slices % num_friends == 0:
    print("Hooray! Everyone gets:", num_slices//num_friends, "pieces")
else:
    print("Oh no! Looks like", num_slices % num_friends, "pieces will be left over.")<jupyter_output><empty_output><jupyter_text>Nested `if` Statements```pythonif [condition_A]:    print("Looks like '[condition_A]' was True")    if [condition_B]:        print("Looks like [condition_B] was True)````  Nested `if` Statements      Nested `if` Statements<jupyter_code># insurance premium calculator
color = "red"
has_racing_kit = True
model = "Prius"

base_premium = 100
if model != "Prius":
    if color == "red":
        base_premium += 50
    if has_racing_kit:
        base_premium += 75
        
print("Total car insurance premium: $", base_premium)<jupyter_output><empty_output><jupyter_text>Nested `if`/`else` Statement<jupyter_code># insurance premium
color = "gold"
has_racing_kit = True
model = "Prius"

base_premium = 100
if model != "Prius":
    if color == "red":
        base_premium += 50
    if has_racing_kit:
        base_premium += 75
else:
    if color == "gold":
        base_premium += 100
    else:
        base_premium -= 15
    
    
print("Total car insurance premium: $", base_premium)<jupyter_output><empty_output><jupyter_text>`elif` Statements- `elif` statements are used to control the execution of more than 2 mutually exclusive blocks of code.- The Python interpreter will start evaluating with the `if` statement and then continue in order until the condition an `elif` is `True` or it reaches the `else` statement ```pythonif [condition_A]:     print("'[condition_A]' was True")elif [condition_B]:    print("'[condition_A]' was False and '[condition_B]' was True")else:    print("Both '[condition_A]' and '[condition_B]' were False")```  `elif` Statements<jupyter_code>speed_limit = 65
current_speed = 66

if current_speed < speed_limit:
    print("You are traveling slower than the speed limit")
elif current_speed == speed_limit:
    print("You are traveling at the speed limit")
else:
    print("You are traveling faster than the speed limit")<jupyter_output><empty_output><jupyter_text>`elif` Statements<jupyter_code>digit = 2

if digit == 0:
    print("zero")
elif digit == 1:
    print("one")
elif digit == 2:
    print("two")
elif digit == 3:
    print("three")
else:
    print("Sorry, I can only count to three...")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11947626841243862, 'fraction_numerical': 0.016366612111292964, 'mean_word_length': 4.522590361445783, 'pattern_counts': {'":': 6, '<': 26, '<?xml version=': 0, '>': 26, 'https://': 2, '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': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '511138', 'license': 'MIT', 'n_tokens_mistral': 1256, 'n_tokens_neox': 1142, 'n_words': 360, 'path': 'CSE20_advanced_branching.ipynb', 'repo_name': 'ryanhausen/cse-20-spring-2021', 'size': '3666'}