-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lecture "Organising information: unordered structures", exercise 3 #22
Comments
#output: {'hobbit': {'Merry', 'Pippin', 'Sam', 'Frodo'}, 'magician': {'Gandalf', 'Saruman'}} |
set_hobbits=({"Frodo","Sam","Pippin","Merry"}) At the end to each of the names in the set_hobbits is assigned key "hobbit", correspondingly to each name in the set_magicians is asssigned - "magician". |
set_hobbit = set() set_magician = set() my_dict = dict() set_hobbit = set() set_magician = set() my_dict = dict() |
|
|
set_hobbit = set({"Frodo", "Sam", "Pippin", "Merry"}) |
|
set_hobbit = set({"Frodo", "Sam", "Pippin", "Merry"}) #what are you doing here? Take you sword and you horse, time to go to Pelennor's field. |
|
|
set_hobbit=set(["Frodo","Sam", "Pippin", "Merry"]) first_dictionary=dict() second_dictionary=dict() first_dictionary.update(second_dictionary) |
|
set_hobbit = set(["Frodo", "Sam", "Pippin", "Merry"]) output {'magician': set(['Gandalf', 'Saruman']), 'hobbit': set(['Frodo', 'Pippin', 'Sam', 'Merry'])} |
set_hobbit = set({"Frodo", "Sam", "Pippin", "Merry"}) my_dictionary = dict() print(my_dictionary) |
set_hobbits = set({"Frodo", "Sam", "Pippin", "Merry"}) middle_earth = dict() print(middle_earth) |
set_hobbit = ({"Frodo", "Sam", "Pippin", "Merry"}) my_first_dictionary = dict() print(my_first_dictionary) output: {'hobbit': {'Sam', 'Pippin', 'Frodo', 'Merry'}, 'magician': {'Gandalf', 'Saruman'}} |
Suppose that all the elements in the set returned by the second exercise have been organised in two different sets, i.e.
set_hobbit
that refers to the setset({"Frodo", "Sam", "Pippin", "Merry"})
, andset_magician
defined asset({"Saruman", "Gandalf"})
. Create a dictionary containing two pairs: one that associate the set of hobbits with the key"hobbit"
, and the other that associates the set of magicians with the key"magician"
.The text was updated successfully, but these errors were encountered: