Week 4: Conditionals and Boolean Logic
Week 4 Goals
-
Learn the Boolean data type
-
Learn the comparison operators:
==,!=,<,<=,>,>= -
Learn the logical operators:
and,or,not -
Learn to use
if/elif/elsestatements to execute code conditionally -
Learn the
%operator for formatting strings
Week 4 Code
-
weather.py: Use an if statement to decide whether a coat is needed -
voting.py: determine if someone is old enough to vote -
movie.py: calculate movie prices based on age -
leapyear.py: Determine if a year is a leap year -
logic_tests.py: test understanding of different logic operations -
stringformatting.py: examples of string formatting -
while_loops.py: examples and exercises with while loops