comp-think / 2020-2021

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. 2020/2021).
14 stars 9 forks source link

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

Open essepuntato opened 4 years ago

essepuntato commented 4 years ago

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

IlaRoss commented 4 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')
penelopelask commented 4 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")
gabrielefiorenza commented 4 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")
ChiaraCati commented 4 years ago
lotr_set = set()

lotr_set.add('Bilbo')
# current state {'Bilbo'}
lotr_set.add('Frodo')
# current state {'Bilbo', 'Frodo'}
lotr_set.add('Sam')
# current state {'Sam', 'Frodo', 'Bilbo'}
lotr_set.add('Pippin')
# current state {'Sam', 'Bilbo', 'Pippin', 'Frodo'}
lotr_set.add('Merry')
print(lotr_set)
# output {'Frodo', 'Sam', 'Merry', 'Pippin', 'Bilbo'}
dbrembilla commented 4 years ago
fellowship_hobbits = set()
fellowship_hobbits.add("Bilbo")
fellowship_hobbits.add("Frodo")
fellowship_hobbits.add("Sam")
fellowship_hobbits.add("Pippin")
fellowship_hobbits.add("Merry")
edoardodalborgo commented 4 years ago
my_set = {'Bilbo', 'Frodo', 'Sam', 'Pippin', 'Merry'}
GiuliaMenna commented 4 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")
output=my_set
giorgiasampo commented 4 years ago

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

print my_set

LuisAmmi commented 4 years ago

    char_set = set()
    char_set.add("Bilbo")
    char_set.add("Frodo")
    char_set.add("Sam")
    char_set.add("Pippin")
    char_set.add("Merry")
    # char_set = { 'Sam', 'Bilbo',  'Frodo',  'Merry', 'Pippin'}
fcagnola commented 4 years ago
# Write a code in Python to create a set of the following elements:
# "Bilbo", "Frodo", "Sam", "Pippin", "Merry".

lotr_set = set()

lotr_set.add("Bilbo")
lotr_set.add("Frodo")
lotr_set.add("Sam")
lotr_set.add("Pippin")
lotr_set.add("Merry")

print(lotr_set)
SofiBar commented 4 years ago

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

print(my_set)`

yunglong28 commented 4 years ago
# Write a code in Python to create a set of the following elements:
# "Bilbo", "Frodo", "Sam", "Pippin", "Merry".

my_set = {"Bilbo", "Frodo", "Sam", "Pippin", "Merry"}
print(my_set)
SarahTew commented 4 years ago
lotr_set={"Bilbo", "Frodo", "Sam", "Pippin", "Merry"}
vanessabonanno commented 4 years ago
hobbit_set = set()
hobbit_set.add("Bilbo")
hobbit_set.add("Frodo")
hobbit_set.add("Sam")
hobbit_set.add("Pippin")
hobbit_set.add("Merry")

print(hobbit_set)

# output: {'Merry', 'Sam', 'Frodo', 'Bilbo', 'Pippin'}
Camillaneri commented 4 years ago

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

print(hobbit_set)

`

AlessandraFa commented 4 years ago
my_lotr_set = set()
my_lotr_set.add("Bilbo")
my_lotr_set.add("​Frodo")
my_lotr_set.add("​Sam")
my_lotr_set.add("​Pippin")
my_lotr_set.add("​Merry")

print(my_lotr_set)

# Output: my_lotr_set = {"​Bilbo", "​Frodo", "​Sam", "​Pippin", "​Merry"}
LauOcchipinti commented 4 years ago

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

AleRosae commented 4 years ago
LOTR_set = set()
LOTR_set.add("Bilbo")
LOTR_set.add("Frodo")
LOTR_set.add("Sam")
LOTR_set.add("Pippin")
LOTR_set.add("Merry")

print(LOTR_set)
SusannaPinotti commented 4 years ago
lotr_set=set()
lotr_set.add("Bilbo")
lotr_set.add("Frodo")
lotr_set.add("Sam")
lotr_set.add("Pippin")
lotr_set.add("Merry")
AlessandroBertozzi commented 4 years ago
my_set = {"Bilbo", "Frodo", "Sam", "Pippin", "Merry"}
print(my_set)
essepuntato commented 4 years ago

Hi all,

thanks for your answer. Just a comment for @giorgiasampo: print my_set is a Python 2 construct, while in Python 3 you should use print(my_set)print is a proper function in Python 3.