PSU CMPSC 101 EXAM 1 STUDY
GUIDE 2025 UPDATE!!
L.index(value) - ANSWERthe index where the value (or first instance of it) is stored
L.count(value) - ANSWERthe number of times the value appears
len(L) - ANSWERnumber of values in list
sum(L) - ANSWERtotal of all values in list
max(L), min(L) - ANSWERmaximum or minimum value
Dictionary Format - ANSWEREx. capitals = {'France':'Paris', 'Egypt':'Cairo'}
Add to Dictionary - ANSWEREx. capitals['Peru'] = 'Lima'
L.append(value) - ANSWERplace an additional value at the end of the list
L.insert(index,value) - ANSWERplace an additional value at specified position
L.remove(value) - ANSWERremove a value (or the first instance of it) from the list
L.pop(index) - ANSWERremove a value from a specified position
Indexing Example - ANSWERmonths = ("Jan","Feb","Mar")
days = ('30','28','31')
answer = input("Month?")
print(answer,'has',days[months.index(answer)])
Reverse List - ANSWERlist.reverse()
GUIDE 2025 UPDATE!!
L.index(value) - ANSWERthe index where the value (or first instance of it) is stored
L.count(value) - ANSWERthe number of times the value appears
len(L) - ANSWERnumber of values in list
sum(L) - ANSWERtotal of all values in list
max(L), min(L) - ANSWERmaximum or minimum value
Dictionary Format - ANSWEREx. capitals = {'France':'Paris', 'Egypt':'Cairo'}
Add to Dictionary - ANSWEREx. capitals['Peru'] = 'Lima'
L.append(value) - ANSWERplace an additional value at the end of the list
L.insert(index,value) - ANSWERplace an additional value at specified position
L.remove(value) - ANSWERremove a value (or the first instance of it) from the list
L.pop(index) - ANSWERremove a value from a specified position
Indexing Example - ANSWERmonths = ("Jan","Feb","Mar")
days = ('30','28','31')
answer = input("Month?")
print(answer,'has',days[months.index(answer)])
Reverse List - ANSWERlist.reverse()