CSC111 surprising behavior

From dftwiki3
Revision as of 08:58, 1 November 2011 by Thiebaut (talk | contribs) (Created page with "--~~~~ ---- <source lang="python"> # What is the surprising behavior # of this program? def f1( L ): L.sort() print( "smallest element of L = ", L[0] ) print( "larg...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

--D. Thiebaut 09:58, 1 November 2011 (EDT)


# What is the surprising behavior
# of this program?


def f1( L ):
    L.sort()
    print( "smallest element of L = ", L[0] )
    print( "largest element of L = ", L[-1] )


def main():
    L = [ 1, 10, 3, 0, -10, 100, 2 ]
    print( "L = ", L )

    f1( L )

    print( "L = ", L )

main()