ejercicio set

Run Settings
LanguagePython
Language Version
Run Command
#Scroll to bottom to see solution # You are working for the school Principal. We have a database of school students: school = {'Bobby','Tammy','Jammy','Sally','Danny'} #during class, the teachers take attendance and compile it into a list. attendance_list = ['Jammy', 'Bobby', 'Danny', 'Sally'] #using what you learned about sets, create a piece of code that the school principal c #an use to immediately find out who missed class so they can call the parents. #(Imagine if the list had 1000s of students. The principal can use the lists generated by the teachers #+ the school database to use python and make his/her job easier): Find the students that miss class nuevo=set(attendance_list) print(nuevo) faltantes= school.difference(nuevo) print('falto el querido: '+ str(faltantes)) #Solution: Notice how we don't have to convert the attendance_list to a set...it does it for you. print(school.difference(attendance_list))
Editor Settings
Theme
Key bindings
Full width
Lines