Skip to content

100 Days of Python

Udemy Angela Yu

Day 3

If Else

if condition: # >,<, >=, <=,==, !=
    do something
else:
    do something else
- modulo uses percent sign - give remainder after division, so 6 % 2 give 0, 5 % 2 gives 1. Often used to check for odd/even numbers. -

NESTED ELIF

if condition:
    if condition:
        # some code here
    else:
        # different code
else:
    # 3rd set of code
if condition:
    # code
elif:
    # code
elif:
    # code
else:
    # Fall through to here

She used draw.io to create a flow chart

Logical Operators

- and, or, not

String Functions

name = "Angela"
name_lower = name.lower() # changes string name to all lower case
num_a = name.count("a") # counts number of a's in the name
  • Multi line strings start and end with three single quotes.
  • askpython.com search for python stuff

tagcheck

tagcheck