''' Purpose: contains some code snippets from the list epistle ''' import math import pause stuff = [] # makes stuff a list with no elements. print( stuff ) pause.enter_when_ready() stuff = [ 'abc', 1112, math.pi ] # initializes stuff to be a three-element list print( 'stuff =', stuff ) pause.enter_when_ready() #he in and not in operations can be used to determine whether a value is or # is not an element of a list. x = 1112 b1 = (x in stuff ) # sets b1 to be True or False depending whether x is an element of stuff b2 = (x not in stuff ) # sets b2 to be True or False depending whether x is not an element of stuff. print( 'x =', x ) print( 'b1 =', b1 ) print( 'b2 =', b2 ) pause.enter_when_ready() stuff = [ 3, 1, 4, 1, 5, 1 ] print( 'stuff =', stuff ) largest = max( stuff ) # sets largest to the maximum a value in stuff. smallest = min( stuff ) # sets smallest to the minimuma value in stuff. print( 'largest =', largest ) print( 'smallest =', smallest ) pause.enter_when_ready() # Unlike strings whose character sequences are immutable once created, lists are mutable. # the values of individual elements can change, and elements can be deleted, inserted # or added. v = 9 stuff.append( v ) # adds v to the end of list stuff. print( 'stuff =', stuff ) pause.enter_when_ready() x = 2 stuff[ x ] = v # sets the xth element of stuff to have value v print( 'stuff =', stuff )