Problem 28E
Find the check digit a15 that follows each of these initial 14 digits of an airline ticket identification number.
a) 10237424413392
b) 00032781811234
c) 00611232134231
d) 00193222543435
CS 1110 Van Loan and Lee Spring 2016 April 5, 2016 Dictionaries o an item has a key and a value values are assigned to keys o set up use a colon to separate a key from its value separate items with a comma enclose the whole thing with {} o dictname.keys() list of keys o dictname.values() list of the values o delete a dictionary item del dictname[‘keyname’] o checking if a dict has a particular key Boolean ‘keyname’ in dictname o extracting a value keys are like subscripts variablename = dictname[‘keyname’] o adding an item to a dictionary dictname[‘nameofkeynotindict’]=value items in a dictionary are randomly ordered if the named key already exists then the value of that key is changed o list vs. dictionary dict: keys mapped to values list: integers (indices) mapped to values o copying dictionaries copy = dict(originaldict) o use loops to go through dictionaries o keys must be strings or numbers, values can be anything all values in a dictionary do not have to have the same type April 7, 2016 Objects and Classes o classes: packages data into units defining the point class build the point given info (using the constructor method) o builds a point object to define a point, you need to define a new type define the attributes of the class __init__ (double underscore function) o initializing, method to write a constructor o “def __init__(self,x,y):” o always start with self the first argument when writing a constructor o under the __init__, assign incoming values to self’s attributes o object holds and organizes data attributes are variables that live in the object use dot notation to access and manipulate attributes pretty printing (define a __str__ method in the class) note: whenever you have a method that is defined in a class in the same module, the first argument is always self method thinking apply the method to a pair of certain objects