comp-think / 2018-2019

The GitHub repository containing all the material related to the Computational Thinking and Programming course of the Digital Humanities and Digital Knowledge degree at the University of Bologna (a.a. 2018/2019).
Other
30 stars 8 forks source link

Lecture "Organising information: unordered structures", exercise 1 #20

Open essepuntato opened 5 years ago

essepuntato commented 5 years ago

Write a pseudocode in Python so as to create a set of the following elements: "​Bilbo"​, "​Frodo"​, "​Sam"​, "​Pippin"​, "​Merry"​.

hizclick commented 5 years ago

my_set = set() my_set.add("Bilbo") my_set.add("Frodo") my_set.add("Sam") my_set.add("Pippin") my_set.add("Merry") print(my_set)

andreamust commented 5 years ago

my_set = set()   # this creates a new set
my_set.add("Bilbo")   # these 5 lines add five names
my_set.add("Frodo")
my_set.add("Sam")
my_set.add("Pippin")
my_set.add("Merry")
print(my_set)
friendlynihilist commented 5 years ago

hobbits = set() #create an empty set and associate it to "hobbits" variable hobbits.add("Bilbo") #add a new element to the set hobbits.add("Frodo") #etc. hobbits.add("Sam") hobbits.add("Pippin") hobbits.add("Merry")

dersuchendee commented 5 years ago

Write a pseudocode in Python so as to create a set of the following elements: "​Bilbo"​, "​Frodo"​, "​Sam"​, "​Pippin"​, "​Merry"​.

set_tolkien= () set_tolkien.add("Bilbo") set_tolkien.add("Frodo") set_tolkien.add("Sam") set_tolkien.add("Pippin") set_tolkien.add("Merry")

Current status of set_tolkien: ({"Bilbo", "Frodo", "Sam", "Pippin", "Merry"})

bluebell94 commented 5 years ago

1 | protagonists=set() 2 | protagonists.add("Bilbo") 3 | protagonists.add("Frodo") 4 | protagonists.add("Sam") 5 | protagonists.add("Pippin") 6 | protagonists.add("Merry") 7 | print (protagonists)

Final set, containing ["Bilbo", "Merry", "Sam", "Pippin","Frodo"]

beccadelbens commented 5 years ago

my_set = set() my_set.add("Bilbo") my_set.add("Frodo") my_set.add("Sam") my_set.add("Pippin") my_set.add("Merry")

print(my_set)

my_set = ({"Bilbo", "Frodo", "Sam", "Pippin", "Merry"})

EleonoraPeruch commented 5 years ago
my_set = set() # create a new set

# add the elements "Bilbo", "Frodo", "Sam", "Pippin", "Merry" 
# in a random order
my_set.add("Bilbo")
my_set.add("Frodo")
my_set.add("Sam")
my_set.add("Pippin")
my_set.add("Merry")

print(my_set)
simayguzel commented 5 years ago
hobbitset = set()
hobbitset.add("Bilbo")
hobbitset.add("Frodo")
hobbitset.add("Sam")
hobbitset.add("Pippin")
hobbitset.add("Merry")
print(hobbitset)

output = {'Sam', 'Bilbo', 'Frodo', 'Merry', 'Pippin'}
leticiasandra commented 5 years ago

my_name_set = set() my_name_set.add("Bilbo") my_name_set.add("Frodo") my_name_set.add("Sam") my_name_set.add("Pippin") my_name_set.add("Merry") my_name_set = ("Bilbo" , "Frodo" , "Sam" , " Pippin" , "Merry") print(my_name_set)

delfimpandiani commented 5 years ago

my_set = set() my_set.add("Bilbo") my_set.add("Frodo") my_set.add("Sam") my_set.add("Pippin") my_set.add("Merry")

MattiaSpadoni commented 5 years ago

sauron_set = set() sauron_set.add("Bilbo") sauron_set.add("Frodo") sauron_set.add("Sam") sauron_set.add("Pippin") sauron_set.add("Merry")

SeverinJB commented 5 years ago
set_der_besten_hobbits = set(["Bilbo","Frodo","Sam","Pippin","Merry"])

OR

set_der_besten_hobbits = set()

set_der_besten_hobbits.add("Bilbo")
set_der_besten_hobbits.add("Frodo")
set_der_besten_hobbits.add("Sam",)
set_der_besten_hobbits.add("Pippin")
set_der_besten_hobbits.add("Merry")
Totaro1996 commented 5 years ago

hobbitset=set() hobbitset.add("Frodo") hobbitset.add("Bilbo") hobbitset.add("Sam") hobbitset.add("Pippin") hobbitset.add("Merry")

print(hobbitset)

ilsamoano commented 5 years ago
mordor_set = set() #used set() to create a new set
mordor_set.add("Bilbo") #added new element to the set
mordor_set.add("Frodo") #added new element to the set
mordor_set.add("Sam") #added new element to the set
mordor_set.add("Pippin") #added new element to the set
mordor_set.add("Merry") #added new element to the set

print(mordor_set)

#{'Frodo', 'Pippin', 'Merry', 'Bilbo', 'Sam'}
saraarmaroli commented 5 years ago

my_set = set() my_set.add("Bilbo") my_set.add("Frodo") my_set.add("Sam") my_set.add("Pippin") my_set.add("Merry")

print(my_set)

my_set: {'Pippin', 'Sam', 'Frodo', 'Bilbo', 'Merry'}

lisasiurina commented 5 years ago

my_set = set() my_set.add("Bilbo") my_set.add("Frodo") my_set.add("Sam") my_set.add("Pippin") my_set.add("Pippin") my_set.add("Merry")

print (my_set)

tceron commented 5 years ago

my_set = set() my_set.add("Bilbo) my_set.add("Frodo") my_set.add("Sam") my_set.add("Pippin") my_set.add("Merry")

print(my_set) Output: my_set {"Pippin", "Sam", "Frodo", "Bilbo", "Merry"}

VittoriaMoccia commented 5 years ago

my_hobbits = set() my_hobbits.add("Bilbo") my_hobbits.add("Frodo") my_hobbits.add("Sam") my_hobbits.add("Pippin") my_hobbits.add("Merry") print(my_hobbits)

MilenaCorbellini commented 5 years ago

esercizio1

DavideApolloni commented 5 years ago

screenshot at dic 01 18-01-19

Saraa04 commented 5 years ago

thehobbits = set() # this creates a new set_

# adding elements to the set without any particular order the_hobbits.add("Bilbo")
the_hobbits.add("Frodo") the_hobbits.add("Sam") the_hobbits.add("Pippin") the_hobbits.add("Merry")

print(the_hobbits)

Output: the_hobbits{'Sam', 'Frodo', 'Bilbo', 'Merry', 'Pippin'}