Jeff's notes of things to mention in lectures related to Chapter 2 in https://automatetheboringstuff.com/2e/chapter2/ Python keywords (some of them, the ones that show up in Chapters 1,2) - https://cs.indstate.edu/wiki/index.php/Cheat_sheet_-_Python_Keywords,_Concepts,_Functions * Concepts / vocabulary - flow chart, boolean, binary operator, unary operator, operator precedence -- Video 1 -- Python operators - https://cs.indstate.edu/wiki/index.php/Cheat_sheet_-_Python_Operators,_Expressions * Arithmetic: + - * / // % (mod) ** * Strings: + concatenation * * Comparison: == != < <= > >= * Assignment: = * Boolean: and or not Simple expressions (only one operator) Compound expressions (more than one operator and order of operations) * Note order of operations - https://docs.python.org/3/reference/expressions.html#evaluation-order Video link - https://youtu.be/irvvKJFNMZU -- Video 2 -- if/elif/else statements * Programs - password checking, math practice, unit conversions Video link - https://youtu.be/Y016WFIZJgk -- Video 3 -- while loop, break, continue * Programs - password checking, math practice, annoying why, total and average Video link - https://youtu.be/E8ct1r02Ge4 -- Video 4 -- for loop, range * Programs - count up, count down, count by, list of perfect squares, list of divisors, checking for letters in a string * Note - another classic use of for loops is to loop through an array (aka list), which we'll see in chapter 3. -- Video 5 -- Random values and simulations * Programs - flip coins, roll dice, * import random * random.randint(1, 6) * random.choice(['H','t']) -- Video 6 -- Other Notes... * Killing a running program - ctrl-c * Conversions to Boolean - automatic ones (0, 0.0, "", None, are all False) * import random, sys, os, math * from random import randint * sys.exit() -- Video 7 -- Programs from the text - * Downloading files used in the book * Guess the number * Rock, Paper, Scissors -- Video for another time -- * Installing sftp program, transferring files between your computer and the CS server * Installing nice text editor on your personal computer -- Resources to links from videos -- * http://www.asciitable.com/ * https://en.wikipedia.org/wiki/Truth_table#Truth_table_for_all_binary_logical_operators * https://docs.python.org/3/reference/expressions.html#evaluation-order -- Notes from video 1 -- testScore: 80.2 testScore >= 80 and testScore < 90 True and testScore < 90 True and True True Check if age is between 25 and 40, or height is between 50 and 80 - if either is the case, then ... age: 20 height: 62 (age >= 25 and age <= 40) or (height >= 50 and height <= 80) False and True or True and True False or True True -- Notes from video 2 -- if BOOLEAN-THING: CODE CODE CODE NOT-IN-THE-LOOP-ANYMORE if BOOLEAN-THING: CODE CODE elif BOOLEAN-THING: CODE CODE else: CODE CODE NOT-IN-THE-LOOP-ANYMORE -- Notes from video 3 -- while CONDITION: CODE CODE CODE NEXT-THING (1) evaluate the CONDITION (2) if CONDITION is True, then (3) run CODE (4) when finished with CODE, go back to (1) () if CONDITION is False, skip past CODE Additional control options... * break - inside of CODE, skip past CODE, we're checking inside the loop to see if it should be done * continue - inside of CODE, go back to (1), we're checking whether to skip the rest of CODE and go to next iteration of the loop "Play computer" * Keep track variables and where in the code we are * Variables ------------ number: 10 11 12 ... * Screen ------------- 11 12 ... # Start spam = 0 while spam < 5: print('Hello World.') spam = spam + 1 # End -- Notes for video 4 -- for VAR_NAME in SOMETHING: CODE CODE CODE range(start, 1_past_end, increment_decrement)