x = 15 coord = 3*(x-2.7) x , = , 15 , , coord , = , 3, *, (, - - PowerPoint PPT Presentation

x 15 coord 3 x 2 7 x 15 coord 3 x 2 7
SMART_READER_LITE
LIVE PREVIEW

x = 15 coord = 3*(x-2.7) x , = , 15 , , coord , = , 3, *, (, - - PowerPoint PPT Presentation

x = 15 coord = 3*(x-2.7) x , = , 15 , , coord , = , 3, *, (, x , - , 2.7, ) ... = = * x 15 coord 3 = x 15 x 2.7 LOAD_CONST 0 # load the literal (constant) at loc. 0 x = 5 y = 7 z = x + y LOAD_CONST LOAD_NAME


slide-1
SLIDE 1
slide-2
SLIDE 2
slide-3
SLIDE 3
slide-4
SLIDE 4
slide-5
SLIDE 5

x = 15 coord = 3*(x-2.7)

slide-6
SLIDE 6

= x 15 x, =, 15, , coord, =, 3, *, (, x, -, 2.7, )

coord x 2.7 – = x = 15 ...

*

3

slide-7
SLIDE 7
slide-8
SLIDE 8
slide-9
SLIDE 9

LOAD_CONST 0 # load the literal (constant) at loc. 0

slide-10
SLIDE 10

x = 5 y = 7 z = x + y

slide-11
SLIDE 11

LOAD_CONST LOAD_NAME STORE_NAME BINARY_ADD BINARY_SUBTRACT

slide-12
SLIDE 12

x = 5 y = 7 z = x + y LOAD_CONST 0 # 5 STORE_NAME 0 # x LOAD_CONST 1 # 7 STORE_NAME 1 # y LOAD_NAME 0 # x LOAD_NAME 1 # y BINARY_ADD STORE_NAME 2 # z

slide-13
SLIDE 13

x = 5 y = 7 z = x + y LOAD_CONST 0 # 5 STORE_NAME 0 # x LOAD_CONST 1 # 7 STORE_NAME 1 # y LOAD_NAME 0 # x LOAD_NAME 1 # y BINARY_ADD STORE_NAME 2 # z

slide-14
SLIDE 14

x = 5 y = 7 z = x + y LOAD_CONST 0 # 5 STORE_NAME 0 # x LOAD_CONST 1 # 7 STORE_NAME 1 # y LOAD_NAME 0 # x LOAD_NAME 1 # y BINARY_ADD STORE_NAME 2 # z

slide-15
SLIDE 15

x = 5 y = 7 z = x + y LOAD_CONST 0 # 5 STORE_NAME 0 # x LOAD_CONST 1 # 7 STORE_NAME 1 # y LOAD_NAME 0 # x LOAD_NAME 1 # y BINARY_ADD STORE_NAME 2 # z

slide-16
SLIDE 16

x = 5 y = 7 z = x + y LOAD_CONST 0 # 5 STORE_NAME 0 # x LOAD_CONST 1 # 7 STORE_NAME 1 # y LOAD_NAME 0 # x LOAD_NAME 1 # y BINARY_ADD STORE_NAME 2 # z

slide-17
SLIDE 17

x = 5 y = 7 z = x + y LOAD_CONST 0 # 5 STORE_NAME 0 # x LOAD_CONST 1 # 7 STORE_NAME 1 # y LOAD_NAME 0 # x LOAD_NAME 1 # y BINARY_ADD STORE_NAME 2 # z

slide-18
SLIDE 18

x = 5 y = 7 z = x + y LOAD_CONST 0 # 5 STORE_NAME 0 # x LOAD_CONST 1 # 7 STORE_NAME 1 # y LOAD_NAME 0 # x LOAD_NAME 1 # y BINARY_ADD STORE_NAME 2 # z

slide-19
SLIDE 19

x = 5 y = 7 z = x + y LOAD_CONST 0 # 5 STORE_NAME 0 # x LOAD_CONST 1 # 7 STORE_NAME 1 # y LOAD_NAME 0 # x LOAD_NAME 1 # y BINARY_ADD STORE_NAME 2 # z

slide-20
SLIDE 20

x = 5 y = 7 z = x + y LOAD_CONST 0 # 5 STORE_NAME 0 # x LOAD_CONST 1 # 7 STORE_NAME 1 # y LOAD_NAME 0 # x LOAD_NAME 1 # y BINARY_ADD STORE_NAME 2 # z

slide-21
SLIDE 21

a b c

LOAD_CONST 0 STORE_NAME 0 LOAD_NAME 0 LOAD_CONST 1 BINARY_SUBTRACT STORE_NAME 1 LOAD_NAME 0 LOAD_NAME 1 BINARY_ADD STORE_NAME 2

slide-22
SLIDE 22

inner

  • uter
  • uter

def inner(x): y = x + 1 return y def outer(x): y = x / 2 return inner(y) + 7 print(outer(4)) inner

  • uter
slide-23
SLIDE 23

def inner(x): y = x + 1 return y def outer(x): y = x / 2 return inner(y) + 7

  • uter(4)

Call Stack [ ] ; outer(4)

slide-24
SLIDE 24

def inner(x): y = x + 1 return y def outer(x): y = x / 2 return inner(y) + 7

  • uter(4)

Call Stack [x=4] ; y = x / 2 [ ] ; outer(4)

slide-25
SLIDE 25

def inner(x): y = x + 1 return y def outer(x): y = x / 2 return inner(y) + 7

  • uter(4)

Call Stack [x=4, y=2.0] ; return inner(y) + 7 [ ] ; outer(4)

slide-26
SLIDE 26

def inner(x): y = x + 1 return y def outer(x): y = x / 2 return inner(y) + 7

  • uter(4)

Call Stack [x=4, y=2.0] ; return inner(2.0) + 7 [ ] ; outer(4) [x=2.0] ; y = x + 1

slide-27
SLIDE 27

def inner(x): y = x + 1 return y def outer(x): y = x / 2 return inner(y) + 7

  • uter(4)

Call Stack [x=4, y=2.0] ; return inner(2.0) + 7 [ ] ; outer(4) [x=2.0, y=3.0] ; return y

slide-28
SLIDE 28

def inner(x): y = x + 1 return y def outer(x): y = x / 2 return inner(y) + 7

  • uter(4)

Call Stack [x=4, y=2.0] ; return 3.0 + 7 [ ] ; outer(4)

slide-29
SLIDE 29

def inner(x): y = x + 1 return y def outer(x): y = x / 2 return inner(y) + 7

  • uter(4)

Call Stack [ ] ; 10.0

slide-30
SLIDE 30
slide-31
SLIDE 31

def payForMeal(cash, cost): cash = cash - cost print("Thanks!") return cash wallet = 20.00 wallet = payForMeal(wallet, 7.25) Call Stack [ ] ; wallet = 20.00 >>>

slide-32
SLIDE 32

def payForMeal(cash, cost): cash = cash - cost print("Thanks!") return cash wallet = 20.00 wallet = payForMeal(wallet, 7.25) Call Stack [ wallet=20.00 ] ; wallet = payForMeal(wallet, 7.25) >>>

slide-33
SLIDE 33

def payForMeal(cash, cost): cash = cash - cost print("Thanks!") return cash wallet = 20.00 wallet = payForMeal(wallet, 7.25) Call Stack [ wallet=20.00 ] ; wallet = payForMeal(20.00, 7.25) [ cash=20.00, cost=7.25 ] ; cash = cash-cost >>>

slide-34
SLIDE 34

>>> def payForMeal(cash, cost): cash = cash - cost print("Thanks!") return cash wallet = 20.00 wallet = payForMeal(wallet, 7.25) Call Stack [ wallet=20.00 ] ; wallet = payForMeal(20.00, 7.25) [ cash=12.75, cost=7.25 ] ; print("Thanks!") Thanks! >>>

slide-35
SLIDE 35

def payForMeal(cash, cost): cash = cash - cost print("Thanks!") return cash wallet = 20.00 wallet = payForMeal(wallet, 7.25) Call Stack [ wallet=20.00 ] ; wallet = payForMeal(20.00, 7.25) [ cash=12.75, cost=7.25 ] ; return cash Thanks! >>>

slide-36
SLIDE 36

def payForMeal(cash, cost): cash = cash - cost print("Thanks!") return cash wallet = 20.00 wallet = payForMeal(wallet, 7.25) Call Stack [ wallet=20.00 ] ; wallet = 12.75 Thanks! >>>

slide-37
SLIDE 37

def payForMeal(cash, cost): cash = cash - cost print("Thanks!") return cash wallet = 20.00 wallet = payForMeal(wallet, 7.25) Call Stack [ wallet=12.75 ] Thanks! >>>

slide-38
SLIDE 38
slide-39
SLIDE 39
slide-40
SLIDE 40

x = @ # @ is not a valid token 4 + 5 = x # the parser stops because it doesn't follow the rules x = 4 # IndentationError: whitespace has meaning print(4 + 5 # Incomplete Error: always close parentheses/quotes

slide-41
SLIDE 41
slide-42
SLIDE 42

print(Hello) # NameError: used a missing variable print("2" + 3) # TypeError: illegal operation on types x = 5 / 0 # ZeroDivisionError: can't divide by zero

slide-43
SLIDE 43
slide-44
SLIDE 44

print("2 + 2 = ", 5) # no error message, but wrong! def double(x): return x + 2 # adding instead of multiplying

slide-45
SLIDE 45
slide-46
SLIDE 46