PFTD lst = ["a","b","c","a"] - - PowerPoint PPT Presentation

pftd
SMART_READER_LITE
LIVE PREVIEW

PFTD lst = ["a","b","c","a"] - - PowerPoint PPT Presentation

Compsci 101 Announcements DeMorgans 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


slide-1
SLIDE 1

Compsci 101 DeMorgan’s Law, Short circuiting, Images, Tuples Live Lecture

10/1/20 Compsci 101, Fall20 1

Susan Rodger October 1, 2020

Announcements

  • APT-4 due Tuesday, Oct. 6
  • Assign 3 due Thursday, Oct 8
  • Lab 5 on Friday
  • Exam 1 – do not discuss until it is handed back.

10/1/20 Compsci 101, Fall20 2

PFTD

  • DeMorgan’s Law
  • Short Circuiting
  • Images & Tuples
  • Start today, finish next class
  • Maybe an APT?

10/1/20 Compsci 101, Fall20 3

Review: Index without error?

lst = ["a","b","c","a"] dex = lst.index("b") lst.index("b") is 1 lst.index("B") ERROR! lst.index("B") ??? -1

  • Use while loop to implement index.
  • What is the while loop’s Boolean condition?

10/1/20 Compsci 101, Fall20 4

dex = 0 while BOOL_CONDITION: dex += 1

slide-2
SLIDE 2

Review: DeMorgan’s Law

  • While loop stopping conditions, stop with either:
  • lst[dex] == elm
  • dex >= len(lst)
  • While loop needs negation: DeMorgan's Laws

not (A and B) equivalent to (not A) or (not B) not (A or B) equivalent to (not A) and (not B)

while not (lst[dex] == elm or dex >= len(lst)): while lst[dex] != elm and dex < len(lst):

10/1/20 Compsci 101, Fall20 5

TPS: DeMorgan’s Law

A B not (A and B) (not A) or (not B) True True False False True False True True False True True True False False True True

10/1/20 Compsci 101, Fall20 6

A B not (A or B) (not A) and (not B) True True False False True False False False False True False False False False True True

Fill in the blanks

WOTO-1: Will this work? http://bit.ly/101f20-1001-1

  • If not, what input will not work?

10/1/20 Compsci 101, Fall20 7

WOTO-2 – Boolean Logic http://bit.ly/101f20-1001-2

  • In your groups:
  • Come to a consensus

10/1/20 Compsci 101, Fall20 11

slide-3
SLIDE 3

Example: Images

10/1/20 Compsci 101, Fall20 12

WOTO-3 – Images http://bit.ly/101f20-1001-3

  • In your groups:
  • Come to a consensus

10/1/20 Compsci 101, Fall20 13 Compsci 101, Fall20 17

APT 3 - TxMsg

10/1/20

Example

Compsci 101, Fall20 18 10/1/20

slide-4
SLIDE 4

WOTO-4 – TxMsg http://bit.ly/101f20-1001-4

  • In your groups:
  • Come to a consensus

10/1/20 Compsci 101, Fall20 19