ARGUMENT NUANCES SETUP In Python function invocations, copies of - - PowerPoint PPT Presentation

argument nuances setup
SMART_READER_LITE
LIVE PREVIEW

ARGUMENT NUANCES SETUP In Python function invocations, copies of - - PowerPoint PPT Presentation

ARGUMENT NUANCES SETUP In Python function invocations, copies of the values of arguments are used to initialize the parameters. This style of parameter passing is known as pass by value . Because copies are used, the values of the arguments


slide-1
SLIDE 1

ARGUMENT NUANCES

slide-2
SLIDE 2
  • In Python function invocations, copies of the values of arguments are used to

initialize the parameters. This style of parameter passing is known as pass by value.

  • Because copies are used, the values of the arguments cannot be modified within the

function being invoked.

SETUP

slide-3
SLIDE 3

Program Program cautionary.py cautionary.py import tale city1 = 'London' city2 = 'Paris’ tale.f( city1, city2 ) print( city1, city2 )

PYTHON FILES

Module Module tale.py tale.py def f( x, y ) : rmbr = x x = y y = rmbr

slide-4
SLIDE 4

Program Program cautionary.py cautionary.py import tale city1 = 'London' city2 = 'Paris’ tale.f tale.f( city1, city2 ) ( city1, city2 ) print( city1, city2 )

PYTHON FILES

Module Module tale.py tale.py def f( x, y ) : rmbr = x x = y y = rmbr main main city1 city2 ’London' 'Paris'

slide-5
SLIDE 5

Program Program cautionary.py cautionary.py import tale city1 = 'London' city2 = 'Paris’ tale.f tale.f( city1, city2 ) ( city1, city2 ) print( city1, city2 )

PYTHON FILES

Module Module tale.py tale.py def f( x, y ) : def f( x, y ) : rmbr = x x = y y = rmbr main main city1 city2 ’London' 'Paris' f() f() rmbr x y

slide-6
SLIDE 6

Program Program cautionary.py cautionary.py import tale city1 = 'London' city2 = 'Paris’ tale.f tale.f( city1, city2 ) ( city1, city2 ) print( city1, city2 )

PYTHON FILES

Module Module tale.py tale.py def f( x, y ) : rmbr = x rmbr = x x = y y = rmbr main main city1 city2 ’London' 'Paris' f() f() rmbr x y

slide-7
SLIDE 7

Program Program cautionary.py cautionary.py import tale city1 = 'London' city2 = 'Paris’ tale.f tale.f( city1, city2 ) ( city1, city2 ) print( city1, city2 )

PYTHON FILES

Module Module tale.py tale.py def f( x, y ) : rmbr = x rmbr = x x = y y = rmbr main main city1 city2 ’London' 'Paris' f() f() rmbr x y

slide-8
SLIDE 8

Program Program cautionary.py cautionary.py import tale city1 = 'London' city2 = 'Paris’ tale.f tale.f( city1, city2 ) ( city1, city2 ) print( city1, city2 )

PYTHON FILES

Module Module tale.py tale.py def f( x, y ) : rmbr = x x = y x = y y = rmbr main main city1 city2 ’London' 'Paris' f() f() rmbr x y

slide-9
SLIDE 9

f() f() rmbr x y Program Program cautionary.py cautionary.py import tale city1 = 'London' city2 = 'Paris’ tale.f tale.f( city1, city2 ) ( city1, city2 ) print( city1, city2 )

PYTHON FILES

Module Module tale.py tale.py def f( x, y ) : rmbr = x x = y x = y y = rmbr main main city1 city2 ’London' 'Paris'

slide-10
SLIDE 10

Program Program cautionary.py cautionary.py import tale city1 = 'London' city2 = 'Paris’ tale.f tale.f( city1, city2 ) ( city1, city2 ) print( city1, city2 )

PYTHON FILES

Module Module tale.py tale.py def f( x, y ) : rmbr = x x = y y = rmbr y = rmbr main main city1 city2 ’London' 'Paris' f() f() rmbr x y

slide-11
SLIDE 11

Program Program cautionary.py cautionary.py import tale city1 = 'London' city2 = 'Paris’ tale.f tale.f( city1, city2 ) ( city1, city2 ) print( city1, city2 )

PYTHON FILES

Module Module tale.py tale.py def f( x, y ) : rmbr = x x = y y = rmbr y = rmbr main main city1 city2 ’London' 'Paris' f() f() rmbr x y

slide-12
SLIDE 12

Program Program cautionary.py cautionary.py import tale city1 = 'London' city2 = 'Paris’ tale.f tale.f( city1, city2 ) ( city1, city2 ) print( city1, city2 )

PYTHON FILES

Module Module tale.py tale.py def f( x, y ) : rmbr = x x = y y = rmbr main main city1 city2 ’London' 'Paris' f() f() rmbr x y main main city1 city2

slide-13
SLIDE 13
slide-14
SLIDE 14

Program Program wipe.py wipe.py import zero nbrs = [ 3, 1, 4 ] zero.out( nbrs ) print( nbrs )

PYTHON FILES

Module Module zero.py zero.py def zero( x) : n = len( x ) for i in range( 0, n ) : x[ i ] = 0

slide-15
SLIDE 15

Program Program wipe.py wipe.py import zero nbrs = [ 3, 1, 4 ] zero.out zero.out( nbrs ) ( nbrs ) print( nbrs )

PYTHON FILES

Module Module zero.py zero.py def out( x) : n = len( x ) for i in range( 0, n ) : x[ i ] = 0 main main nbrs 3 1 4

slide-16
SLIDE 16

Program Program wipe.py wipe.py import zero nbrs = [ 3, 1, 4 ] zero.out zero.out( nbrs ) ( nbrs ) print( nbrs )

PYTHON FILES

Module Module zero.py zero.py def out( x) : def out( x) : n = len( x ) for i in range( 0, n ) : x[ i ] = 0 main main nbrs 3 1 4

  • ut()
  • ut()

x i n

slide-17
SLIDE 17
  • ut()
  • ut()

x i n Program Program wipe.py wipe.py import zero nbrs = [ 3, 1, 4 ] zero.out zero.out( nbrs ) ( nbrs ) print( nbrs )

PYTHON FILES

Module Module zero.py zero.py def out( x) : def out( x) : n = len( x ) for i in range( 0, n ) : x[ i ] = 0 main main nbrs 3 1 4

slide-18
SLIDE 18
  • ut()
  • ut()

x i n Program Program wipe.py wipe.py import zero nbrs = [ 3, 1, 4 ] zero.out zero.out( nbrs ) ( nbrs ) print( nbrs )

PYTHON FILES

Module Module zero.py zero.py def out( x) : def out( x) : n = n = len len( x ) ( x ) for i in range( 0, n ) : x[ i ] = 0 main main nbrs 3 1 4

slide-19
SLIDE 19
  • ut()
  • ut()

x i 3 n Program Program wipe.py wipe.py import zero nbrs = [ 3, 1, 4 ] zero.out zero.out( nbrs ) ( nbrs ) print( nbrs )

PYTHON FILES

Module Module zero.py zero.py def out( x) : def out( x) : n = n = len len( x ) ( x ) for i in range( 0, n ) : x[ i ] = 0 main main nbrs 3 1 4

slide-20
SLIDE 20
  • ut()
  • ut()

x i 3 n Program Program wipe.py wipe.py import zero nbrs = [ 3, 1, 4 ] zero.out zero.out( nbrs ) ( nbrs ) print( nbrs )

PYTHON FILES

Module Module zero.py zero.py def out( x) : def out( x) : n = len( x ) for for i in range( 0, n ) : in range( 0, n ) : x[ i ] = 0 main main nbrs 3 1 4

slide-21
SLIDE 21
  • ut()
  • ut()

x i 3 n Program Program wipe.py wipe.py import zero nbrs = [ 3, 1, 4 ] zero.out zero.out( nbrs ) ( nbrs ) print( nbrs )

PYTHON FILES

Module Module zero.py zero.py def out( x) : def out( x) : n = len( x ) for for i in range( 0, n ) : in range( 0, n ) : x[ i ] = 0 main main nbrs 3 1 4

slide-22
SLIDE 22
  • ut()
  • ut()

x i 3 n Program Program wipe.py wipe.py import zero nbrs = [ 3, 1, 4 ] zero.out zero.out( nbrs ) ( nbrs ) print( nbrs )

PYTHON FILES

Module Module zero.py zero.py def out( x) : def out( x) : n = len( x ) for i in range( 0, n ) : x[ x[ i ] = 0 ] = 0 main main nbrs 3 1 4

slide-23
SLIDE 23
  • ut()
  • ut()

x i 3 n Program Program wipe.py wipe.py import zero nbrs = [ 3, 1, 4 ] zero.out zero.out( nbrs ) ( nbrs ) print( nbrs )

PYTHON FILES

Module Module zero.py zero.py def out( x) : def out( x) : n = len( x ) for i in range( 0, n ) : x[ x[ i ] = 0 ] = 0 main main nbrs 1 4

slide-24
SLIDE 24
  • ut()
  • ut()

x i 3 n Program Program wipe.py wipe.py import zero nbrs = [ 3, 1, 4 ] zero.out zero.out( nbrs ) ( nbrs ) print( nbrs )

PYTHON FILES

Module Module zero.py zero.py def out( x) : def out( x) : n = len( x ) for for i in range( 0, n ) : in range( 0, n ) : x[ i ] = 0 main main nbrs 1 4

slide-25
SLIDE 25
  • ut()
  • ut()

x 1 i 3 n Program Program wipe.py wipe.py import zero nbrs = [ 3, 1, 4 ] zero.out zero.out( nbrs ) ( nbrs ) print( nbrs )

PYTHON FILES

Module Module zero.py zero.py def out( x) : def out( x) : n = len( x ) for for i in range( 0, n ) : in range( 0, n ) : x[ i ] = 0 main main nbrs 1 4

slide-26
SLIDE 26
  • ut()
  • ut()

x 1 i 3 n Program Program wipe.py wipe.py import zero nbrs = [ 3, 1, 4 ] zero.out zero.out( nbrs ) ( nbrs ) print( nbrs )

PYTHON FILES

Module Module zero.py zero.py def out( x) : def out( x) : n = len( x ) for i in range( 0, n ) : x[ x[ i ] = 0 ] = 0 main main nbrs 1 4

slide-27
SLIDE 27
  • ut()
  • ut()

x 1 i 3 n Program Program wipe.py wipe.py import zero nbrs = [ 3, 1, 4 ] zero.out zero.out( nbrs ) ( nbrs ) print( nbrs )

PYTHON FILES

Module Module zero.py zero.py def out( x) : def out( x) : n = len( x ) for i in range( 0, n ) : x[ x[ i ] = 0 ] = 0 main main nbrs 4

slide-28
SLIDE 28
  • ut()
  • ut()

x 1 i 3 n Program Program wipe.py wipe.py import zero nbrs = [ 3, 1, 4 ] zero.out zero.out( nbrs ) ( nbrs ) print( nbrs )

PYTHON FILES

Module Module zero.py zero.py def out( x) : def out( x) : n = len( x ) for for i in range( 0, n ) : in range( 0, n ) : x[ i ] = 0 main main nbrs 4

slide-29
SLIDE 29
  • ut()
  • ut()

x 2 i 3 n Program Program wipe.py wipe.py import zero nbrs = [ 3, 1, 4 ] zero.out zero.out( nbrs ) ( nbrs ) print( nbrs )

PYTHON FILES

Module Module zero.py zero.py def out( x) : def out( x) : n = len( x ) for for i in range( 0, n ) : in range( 0, n ) : x[ i ] = 0 main main nbrs 4

slide-30
SLIDE 30
  • ut()
  • ut()

x 2 i 3 n Program Program wipe.py wipe.py import zero nbrs = [ 3, 1, 4 ] zero.out zero.out( nbrs ) ( nbrs ) print( nbrs )

PYTHON FILES

Module Module zero.py zero.py def out( x) : def out( x) : n = len( x ) for i in range( 0, n ) : x[ x[ i ] = 0 ] = 0 main main nbrs 4

slide-31
SLIDE 31
  • ut()
  • ut()

x 2 i 3 n Program Program wipe.py wipe.py import zero nbrs = [ 3, 1, 4 ] zero.out zero.out( nbrs ) ( nbrs ) print( nbrs )

PYTHON FILES

Module Module zero.py zero.py def out( x) : def out( x) : n = len( x ) for i in range( 0, n ) : x[ x[ i ] = 0 ] = 0 main main nbrs

slide-32
SLIDE 32
  • ut()
  • ut()

x 2 i 3 n Program Program wipe.py wipe.py import zero nbrs = [ 3, 1, 4 ] zero.out zero.out( nbrs ) ( nbrs ) print( nbrs )

PYTHON FILES

Module Module zero.py zero.py def out( x) : def out( x) : n = len( x ) for for i in range( 0, n ) : in range( 0, n ) : x[ i ] = 0 main main nbrs

slide-33
SLIDE 33
  • ut()
  • ut()

x 2 i 3 n Program Program wipe.py wipe.py import zero nbrs = [ 3, 1, 4 ] zero.out zero.out( nbrs ) ( nbrs ) print( nbrs )

PYTHON FILES

Module Module zero.py zero.py def out( x) : def out( x) : n = len( x ) for i in range( 0, n ) : x[ i ] = 0 main main nbrs main main nbrs

slide-34
SLIDE 34

Program Program wipe.py wipe.py import zero nbrs = [ 3, 1, 4 ] zero.out( nbrs ) print( nbrs ) print( nbrs )

PYTHON FILES

Module Module zero.py zero.py def out( x) : def out( x) : n = len( x ) for i in range( 0, n ) : x[ i ] = 0 main main nbrs main main nbrs