ARGUMENT NUANCEScs1112/term/183/meetings/30/...Program cautionary.py import tale city1 = 'London'...

34
ARGUMENT NUANCES

Transcript of ARGUMENT NUANCEScs1112/term/183/meetings/30/...Program cautionary.py import tale city1 = 'London'...

Page 1: ARGUMENT NUANCEScs1112/term/183/meetings/30/...Program cautionary.py import tale city1 = 'London' city2 = 'Paris’ tale.f( city1, city2 ) print( city1, city2 ) PYTHON FILES Module

ARGUMENT NUANCES

Page 2: ARGUMENT NUANCEScs1112/term/183/meetings/30/...Program cautionary.py import tale city1 = 'London' city2 = 'Paris’ tale.f( city1, city2 ) print( city1, city2 ) PYTHON FILES Module

• 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

Page 3: ARGUMENT NUANCEScs1112/term/183/meetings/30/...Program cautionary.py import tale city1 = 'London' city2 = 'Paris’ tale.f( city1, city2 ) print( city1, city2 ) PYTHON FILES Module

Program cautionary.py

import tale

city1 = 'London'

city2 = 'Paris’

tale.f( city1, city2 )

print( city1, city2 )

PYTHON FILES

Module tale.py

def f( x, y ) :

rmbr = x

x = y

y = rmbr

Page 4: ARGUMENT NUANCEScs1112/term/183/meetings/30/...Program cautionary.py import tale city1 = 'London' city2 = 'Paris’ tale.f( city1, city2 ) print( city1, city2 ) PYTHON FILES Module

Program cautionary.py

import tale

city1 = 'London'

city2 = 'Paris’

tale.f( city1, city2 )

print( city1, city2 )

PYTHON FILES

Module tale.py

def f( x, y ) :

rmbr = x

x = y

y = rmbr

main

city1

city2

’London'

'Paris'

Page 5: ARGUMENT NUANCEScs1112/term/183/meetings/30/...Program cautionary.py import tale city1 = 'London' city2 = 'Paris’ tale.f( city1, city2 ) print( city1, city2 ) PYTHON FILES Module

Program cautionary.py

import tale

city1 = 'London'

city2 = 'Paris’

tale.f( city1, city2 )

print( city1, city2 )

PYTHON FILES

Module tale.py

def f( x, y ) :

rmbr = x

x = y

y = rmbr

main

city1

city2

’London'

'Paris'

f()

rmbr

x

y

Page 6: ARGUMENT NUANCEScs1112/term/183/meetings/30/...Program cautionary.py import tale city1 = 'London' city2 = 'Paris’ tale.f( city1, city2 ) print( city1, city2 ) PYTHON FILES Module

Program cautionary.py

import tale

city1 = 'London'

city2 = 'Paris’

tale.f( city1, city2 )

print( city1, city2 )

PYTHON FILES

Module tale.py

def f( x, y ) :

rmbr = x

x = y

y = rmbr

main

city1

city2

’London'

'Paris'

f()

rmbr

x

y

Page 7: ARGUMENT NUANCEScs1112/term/183/meetings/30/...Program cautionary.py import tale city1 = 'London' city2 = 'Paris’ tale.f( city1, city2 ) print( city1, city2 ) PYTHON FILES Module

Program cautionary.py

import tale

city1 = 'London'

city2 = 'Paris’

tale.f( city1, city2 )

print( city1, city2 )

PYTHON FILES

Module tale.py

def f( x, y ) :

rmbr = x

x = y

y = rmbr

main

city1

city2

’London'

'Paris'

f()

rmbr

x

y

Page 8: ARGUMENT NUANCEScs1112/term/183/meetings/30/...Program cautionary.py import tale city1 = 'London' city2 = 'Paris’ tale.f( city1, city2 ) print( city1, city2 ) PYTHON FILES Module

Program cautionary.py

import tale

city1 = 'London'

city2 = 'Paris’

tale.f( city1, city2 )

print( city1, city2 )

PYTHON FILES

Module tale.py

def f( x, y ) :

rmbr = x

x = y

y = rmbr

main

city1

city2

’London'

'Paris'

f()

rmbr

x

y

Page 9: ARGUMENT NUANCEScs1112/term/183/meetings/30/...Program cautionary.py import tale city1 = 'London' city2 = 'Paris’ tale.f( city1, city2 ) print( city1, city2 ) PYTHON FILES Module

f()

rmbr

x

y

Program cautionary.py

import tale

city1 = 'London'

city2 = 'Paris’

tale.f( city1, city2 )

print( city1, city2 )

PYTHON FILES

Module tale.py

def f( x, y ) :

rmbr = x

x = y

y = rmbr

main

city1

city2

’London'

'Paris'

Page 10: ARGUMENT NUANCEScs1112/term/183/meetings/30/...Program cautionary.py import tale city1 = 'London' city2 = 'Paris’ tale.f( city1, city2 ) print( city1, city2 ) PYTHON FILES Module

Program cautionary.py

import tale

city1 = 'London'

city2 = 'Paris’

tale.f( city1, city2 )

print( city1, city2 )

PYTHON FILES

Module tale.py

def f( x, y ) :

rmbr = x

x = y

y = rmbr

main

city1

city2

’London'

'Paris'

f()

rmbr

x

y

Page 11: ARGUMENT NUANCEScs1112/term/183/meetings/30/...Program cautionary.py import tale city1 = 'London' city2 = 'Paris’ tale.f( city1, city2 ) print( city1, city2 ) PYTHON FILES Module

Program cautionary.py

import tale

city1 = 'London'

city2 = 'Paris’

tale.f( city1, city2 )

print( city1, city2 )

PYTHON FILES

Module tale.py

def f( x, y ) :

rmbr = x

x = y

y = rmbr

main

city1

city2

’London'

'Paris'

f()

rmbr

x

y

Page 12: ARGUMENT NUANCEScs1112/term/183/meetings/30/...Program cautionary.py import tale city1 = 'London' city2 = 'Paris’ tale.f( city1, city2 ) print( city1, city2 ) PYTHON FILES Module

Program cautionary.py

import tale

city1 = 'London'

city2 = 'Paris’

tale.f( city1, city2 )

print( city1, city2 )

PYTHON FILES

Module tale.py

def f( x, y ) :

rmbr = x

x = y

y = rmbr

main

city1

city2

’London'

'Paris'

f()

rmbr

x

y

main

city1

city2

Page 13: ARGUMENT NUANCEScs1112/term/183/meetings/30/...Program cautionary.py import tale city1 = 'London' city2 = 'Paris’ tale.f( city1, city2 ) print( city1, city2 ) PYTHON FILES Module
Page 14: ARGUMENT NUANCEScs1112/term/183/meetings/30/...Program cautionary.py import tale city1 = 'London' city2 = 'Paris’ tale.f( city1, city2 ) print( city1, city2 ) PYTHON FILES Module

Program wipe.py

import zero

nbrs = [ 3, 1, 4 ]

zero.out( nbrs )

print( nbrs )

PYTHON FILES

Module zero.py

def zero( x) :

n = len( x )

for i in range( 0, n ) :

x[ i ] = 0

Page 15: ARGUMENT NUANCEScs1112/term/183/meetings/30/...Program cautionary.py import tale city1 = 'London' city2 = 'Paris’ tale.f( city1, city2 ) print( city1, city2 ) PYTHON FILES Module

Program wipe.py

import zero

nbrs = [ 3, 1, 4 ]

zero.out( nbrs )

print( nbrs )

PYTHON FILES

Module zero.py

def out( x) :

n = len( x )

for i in range( 0, n ) :

x[ i ] = 0

main

nbrs 3 1 4

Page 16: ARGUMENT NUANCEScs1112/term/183/meetings/30/...Program cautionary.py import tale city1 = 'London' city2 = 'Paris’ tale.f( city1, city2 ) print( city1, city2 ) PYTHON FILES Module

Program wipe.py

import zero

nbrs = [ 3, 1, 4 ]

zero.out( nbrs )

print( nbrs )

PYTHON FILES

Module zero.py

def out( x) :

n = len( x )

for i in range( 0, n ) :

x[ i ] = 0

main

nbrs 3 1 4

out()

x

i

n

Page 17: ARGUMENT NUANCEScs1112/term/183/meetings/30/...Program cautionary.py import tale city1 = 'London' city2 = 'Paris’ tale.f( city1, city2 ) print( city1, city2 ) PYTHON FILES Module

out()

x

i

n

Program wipe.py

import zero

nbrs = [ 3, 1, 4 ]

zero.out( nbrs )

print( nbrs )

PYTHON FILES

Module zero.py

def out( x) :

n = len( x )

for i in range( 0, n ) :

x[ i ] = 0

main

nbrs 3 1 4

Page 18: ARGUMENT NUANCEScs1112/term/183/meetings/30/...Program cautionary.py import tale city1 = 'London' city2 = 'Paris’ tale.f( city1, city2 ) print( city1, city2 ) PYTHON FILES Module

out()

x

i

n

Program wipe.py

import zero

nbrs = [ 3, 1, 4 ]

zero.out( nbrs )

print( nbrs )

PYTHON FILES

Module zero.py

def out( x) :

n = len( x )

for i in range( 0, n ) :

x[ i ] = 0

main

nbrs 3 1 4

Page 19: ARGUMENT NUANCEScs1112/term/183/meetings/30/...Program cautionary.py import tale city1 = 'London' city2 = 'Paris’ tale.f( city1, city2 ) print( city1, city2 ) PYTHON FILES Module

out()

x

i

3 n

Program wipe.py

import zero

nbrs = [ 3, 1, 4 ]

zero.out( nbrs )

print( nbrs )

PYTHON FILES

Module zero.py

def out( x) :

n = len( x )

for i in range( 0, n ) :

x[ i ] = 0

main

nbrs 3 1 4

Page 20: ARGUMENT NUANCEScs1112/term/183/meetings/30/...Program cautionary.py import tale city1 = 'London' city2 = 'Paris’ tale.f( city1, city2 ) print( city1, city2 ) PYTHON FILES Module

out()

x

i

3 n

Program wipe.py

import zero

nbrs = [ 3, 1, 4 ]

zero.out( nbrs )

print( nbrs )

PYTHON FILES

Module zero.py

def out( x) :

n = len( x )

for i in range( 0, n ) :

x[ i ] = 0

main

nbrs 3 1 4

Page 21: ARGUMENT NUANCEScs1112/term/183/meetings/30/...Program cautionary.py import tale city1 = 'London' city2 = 'Paris’ tale.f( city1, city2 ) print( city1, city2 ) PYTHON FILES Module

out()

x

0 i

3 n

Program wipe.py

import zero

nbrs = [ 3, 1, 4 ]

zero.out( nbrs )

print( nbrs )

PYTHON FILES

Module zero.py

def out( x) :

n = len( x )

for i in range( 0, n ) :

x[ i ] = 0

main

nbrs 3 1 4

Page 22: ARGUMENT NUANCEScs1112/term/183/meetings/30/...Program cautionary.py import tale city1 = 'London' city2 = 'Paris’ tale.f( city1, city2 ) print( city1, city2 ) PYTHON FILES Module

out()

x

0 i

3 n

Program wipe.py

import zero

nbrs = [ 3, 1, 4 ]

zero.out( nbrs )

print( nbrs )

PYTHON FILES

Module zero.py

def out( x) :

n = len( x )

for i in range( 0, n ) :

x[ i ] = 0

main

nbrs 3 1 4

Page 23: ARGUMENT NUANCEScs1112/term/183/meetings/30/...Program cautionary.py import tale city1 = 'London' city2 = 'Paris’ tale.f( city1, city2 ) print( city1, city2 ) PYTHON FILES Module

out()

x

0 i

3 n

Program wipe.py

import zero

nbrs = [ 3, 1, 4 ]

zero.out( nbrs )

print( nbrs )

PYTHON FILES

Module zero.py

def out( x) :

n = len( x )

for i in range( 0, n ) :

x[ i ] = 0

main

nbrs 0 1 4

Page 24: ARGUMENT NUANCEScs1112/term/183/meetings/30/...Program cautionary.py import tale city1 = 'London' city2 = 'Paris’ tale.f( city1, city2 ) print( city1, city2 ) PYTHON FILES Module

out()

x

0 i

3 n

Program wipe.py

import zero

nbrs = [ 3, 1, 4 ]

zero.out( nbrs )

print( nbrs )

PYTHON FILES

Module zero.py

def out( x) :

n = len( x )

for i in range( 0, n ) :

x[ i ] = 0

main

nbrs 0 1 4

Page 25: ARGUMENT NUANCEScs1112/term/183/meetings/30/...Program cautionary.py import tale city1 = 'London' city2 = 'Paris’ tale.f( city1, city2 ) print( city1, city2 ) PYTHON FILES Module

out()

x

1 i

3 n

Program wipe.py

import zero

nbrs = [ 3, 1, 4 ]

zero.out( nbrs )

print( nbrs )

PYTHON FILES

Module zero.py

def out( x) :

n = len( x )

for i in range( 0, n ) :

x[ i ] = 0

main

nbrs 0 1 4

Page 26: ARGUMENT NUANCEScs1112/term/183/meetings/30/...Program cautionary.py import tale city1 = 'London' city2 = 'Paris’ tale.f( city1, city2 ) print( city1, city2 ) PYTHON FILES Module

out()

x

1 i

3 n

Program wipe.py

import zero

nbrs = [ 3, 1, 4 ]

zero.out( nbrs )

print( nbrs )

PYTHON FILES

Module zero.py

def out( x) :

n = len( x )

for i in range( 0, n ) :

x[ i ] = 0

main

nbrs 0 1 4

Page 27: ARGUMENT NUANCEScs1112/term/183/meetings/30/...Program cautionary.py import tale city1 = 'London' city2 = 'Paris’ tale.f( city1, city2 ) print( city1, city2 ) PYTHON FILES Module

out()

x

1 i

3 n

Program wipe.py

import zero

nbrs = [ 3, 1, 4 ]

zero.out( nbrs )

print( nbrs )

PYTHON FILES

Module zero.py

def out( x) :

n = len( x )

for i in range( 0, n ) :

x[ i ] = 0

main

nbrs 0 0 4

Page 28: ARGUMENT NUANCEScs1112/term/183/meetings/30/...Program cautionary.py import tale city1 = 'London' city2 = 'Paris’ tale.f( city1, city2 ) print( city1, city2 ) PYTHON FILES Module

out()

x

1 i

3 n

Program wipe.py

import zero

nbrs = [ 3, 1, 4 ]

zero.out( nbrs )

print( nbrs )

PYTHON FILES

Module zero.py

def out( x) :

n = len( x )

for i in range( 0, n ) :

x[ i ] = 0

main

nbrs 0 0 4

Page 29: ARGUMENT NUANCEScs1112/term/183/meetings/30/...Program cautionary.py import tale city1 = 'London' city2 = 'Paris’ tale.f( city1, city2 ) print( city1, city2 ) PYTHON FILES Module

out()

x

2 i

3 n

Program wipe.py

import zero

nbrs = [ 3, 1, 4 ]

zero.out( nbrs )

print( nbrs )

PYTHON FILES

Module zero.py

def out( x) :

n = len( x )

for i in range( 0, n ) :

x[ i ] = 0

main

nbrs 0 0 4

Page 30: ARGUMENT NUANCEScs1112/term/183/meetings/30/...Program cautionary.py import tale city1 = 'London' city2 = 'Paris’ tale.f( city1, city2 ) print( city1, city2 ) PYTHON FILES Module

out()

x

2 i

3 n

Program wipe.py

import zero

nbrs = [ 3, 1, 4 ]

zero.out( nbrs )

print( nbrs )

PYTHON FILES

Module zero.py

def out( x) :

n = len( x )

for i in range( 0, n ) :

x[ i ] = 0

main

nbrs 0 0 4

Page 31: ARGUMENT NUANCEScs1112/term/183/meetings/30/...Program cautionary.py import tale city1 = 'London' city2 = 'Paris’ tale.f( city1, city2 ) print( city1, city2 ) PYTHON FILES Module

out()

x

2 i

3 n

Program wipe.py

import zero

nbrs = [ 3, 1, 4 ]

zero.out( nbrs )

print( nbrs )

PYTHON FILES

Module zero.py

def out( x) :

n = len( x )

for i in range( 0, n ) :

x[ i ] = 0

main

nbrs 0 0 0

Page 32: ARGUMENT NUANCEScs1112/term/183/meetings/30/...Program cautionary.py import tale city1 = 'London' city2 = 'Paris’ tale.f( city1, city2 ) print( city1, city2 ) PYTHON FILES Module

out()

x

2 i

3 n

Program wipe.py

import zero

nbrs = [ 3, 1, 4 ]

zero.out( nbrs )

print( nbrs )

PYTHON FILES

Module zero.py

def out( x) :

n = len( x )

for i in range( 0, n ) :

x[ i ] = 0

main

nbrs 0 0 0

Page 33: ARGUMENT NUANCEScs1112/term/183/meetings/30/...Program cautionary.py import tale city1 = 'London' city2 = 'Paris’ tale.f( city1, city2 ) print( city1, city2 ) PYTHON FILES Module

out()

x

2 i

3 n

Program wipe.py

import zero

nbrs = [ 3, 1, 4 ]

zero.out( nbrs )

print( nbrs )

PYTHON FILES

Module zero.py

def out( x) :

n = len( x )

for i in range( 0, n ) :

x[ i ] = 0

main

nbrs 0 0 0

main

nbrs

Page 34: ARGUMENT NUANCEScs1112/term/183/meetings/30/...Program cautionary.py import tale city1 = 'London' city2 = 'Paris’ tale.f( city1, city2 ) print( city1, city2 ) PYTHON FILES Module

Program wipe.py

import zero

nbrs = [ 3, 1, 4 ]

zero.out( nbrs )

print( nbrs )

PYTHON FILES

Module zero.py

def out( x) :

n = len( x )

for i in range( 0, n ) :

x[ i ] = 0

main

nbrs 0 0 0

main

nbrs