Compsci 101 Announcements DeMorgan’s Law, Short circuiting, • APT-4 due Tuesday, Oct. 6 Images, Tuples • Assign 3 due Thursday, Oct 8 Live Lecture • Lab 5 on Friday Susan Rodger October 1, 2020 • Exam 1 – do not discuss until it is handed back. 10/1/20 Compsci 101, Fall20 1 10/1/20 Compsci 101, Fall20 2 Review: Index without error? PFTD lst = ["a","b","c","a"] • DeMorgan’s Law dex = lst.index("b") lst.index("b") is 1 • Short Circuiting lst.index("B") ERROR! • Images & Tuples lst.index("B") ??? -1 • Start today, finish next class • Maybe an APT? • Use while loop to implement index. • What is the while loop’s Boolean condition? dex = 0 while BOOL_CONDITION: dex += 1 10/1/20 Compsci 101, Fall20 3 10/1/20 Compsci 101, Fall20 4
Fill in the Review: DeMorgan’s Law TPS: DeMorgan’s Law blanks A B not (A and B) (not A) or (not B) • While loop stopping conditions, stop with either: True True False False • lst[dex] == elm True False True True • dex >= len(lst) False True True True • While loop needs negation: DeMorgan's Laws False False True True not (A and B) equivalent to ( not A) or (not B) not (A or B) equivalent to ( not A) and (not B) A B not (A or B) (not A) and (not B) True True False False while not (lst[dex] == elm or dex >= len(lst)): True False False False False True False False while lst[dex] != elm and dex < len(lst): False False True True 10/1/20 Compsci 101, Fall20 5 10/1/20 Compsci 101, Fall20 6 WOTO-1: Will this work? WOTO-2 – Boolean Logic http://bit.ly/101f20-1001-1 http://bit.ly/101f20-1001-2 • If not, what input will not work? • In your groups: • Come to a consensus 10/1/20 Compsci 101, Fall20 7 10/1/20 Compsci 101, Fall20 11
WOTO-3 – Images Example: Images http://bit.ly/101f20-1001-3 • In your groups: • Come to a consensus 10/1/20 Compsci 101, Fall20 12 10/1/20 Compsci 101, Fall20 13 APT 3 - TxMsg Example 10/1/20 Compsci 101, Fall20 17 10/1/20 Compsci 101, Fall20 18
WOTO-4 – TxMsg http://bit.ly/101f20-1001-4 • In your groups: • Come to a consensus 10/1/20 Compsci 101, Fall20 19
More recommend