Quiz #3

create a list called students with the names John, Paul, George, and Ringo:

students = ['John','Paul','George','Ringo']

you want to put the students list in alphabetical order in Python and dont care if you keep the original order

students.sort()

you want to put the students list in alphabetical order yet keep the original order

sorted_students= sorted(students)

print the last value in the students list assuming you dont know the length of the list

print(students[-1])

print the items in the students list backwards

print(students[-1], students[-2],students[-3],students[-4])

add the name Yoko to the students list

students.append('Yoko')

remove the name John from the list based on location

students.pop(0)

remove the name ringo from the list based on value

students.remove('Ringo')

write a for loop to loop through the students list and prints each item

for student in students:
print(student)

find the value "united states" in the united nations list and save it to the variable memberNation. wrap this line in a try except block. give user feedback in the except portion of the block

try:
memberNation= unitednations.index('united states')
except:
print('not found')

create a dictionary called music with 2 entries where the artist is the key and the song is the value

music= {'taylor swift' : '22', ' drake' : 'free smoke'}

save the song single ladies to a variable beyonceSong using beyonce as the key

music['beyonce'] = 'single ladies'
beyoncesong= music['beyonce']

change the song associated with beyonce to lemonade

music['beyonce']= 'lemonade'

add another song

music['lil pump']= 'gucci gang'

delete beyonce from the dictionary

del music ['beyonce']

add 'so what' and 'smoke gets in your eyes' sung by miles davis to the music dictionary as a list

music['miles davis'] = ['so what', 'smoke gets in your eyes']

write a for loop that prints all the entries in the music dictionary for miles davis

for song in music['miles davis']:
print(song)