Quick actions

cmd+k|ctrl+k

Navigation

Languages

ejercicio set

Snippet info

Language

Python

Visibility

public

Author

lchicaiza

Created

2025-07-03T01:07:09.350927Z

Updated

2025-07-03T01:07:09.350927Z

#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))
INFO