Skip to content
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 1 #21

Open
essepuntato opened this issue Nov 8, 2020 · 21 comments
Open
Labels

Comments

@essepuntato
Copy link
Contributor

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

@IlaRoss
Copy link

IlaRoss commented Nov 9, 2020

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

@penelopelask
Copy link

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

@gabrielefiorenza
Copy link

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

@ChiaraCati
Copy link

ChiaraCati commented Nov 9, 2020

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
Copy link

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

@edoardodalborgo
Copy link

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

@GiuliaMenna
Copy link

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
Copy link

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
Copy link

LuisAmmi commented Nov 10, 2020

    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
Copy link

# 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
Copy link

SofiBar commented Nov 10, 2020

`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
Copy link

# 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
Copy link

lotr_set={"Bilbo", "Frodo", "Sam", "Pippin", "Merry"}

@vanessabonanno
Copy link

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
Copy link

`
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
Copy link

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
Copy link

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

@AleRosae
Copy link

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
Copy link

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

@AlessandroBertozzi
Copy link

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

@essepuntato
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests