Skip to content

Emma Cunill: challenge 1 done - #3

Open
emmacunill wants to merge 3 commits into
Ironhack-data-bcn-oct-2023:mainfrom
trainwithlabs:main
Open

Emma Cunill: challenge 1 done#3
emmacunill wants to merge 3 commits into
Ironhack-data-bcn-oct-2023:mainfrom
trainwithlabs:main

Conversation

@emmacunill

Copy link
Copy Markdown

No description provided.

@bripollc

Copy link
Copy Markdown

Hola Emma,

Felicidades!!!!!!!!! Tengo poco que decirte porque has hecho un muy buen segundo lab:)

Challenge 1: todo correcto, está perfecto!
Lo único:

  1. Now try to append the following elements to tup.
tup_append = tup + ("r","o", "n", "h", "a", "c", "k")
print(tup_append)

De esta manera te funcionará:)

  1. How about re-assign a new value to an existing tuple?
tup = list(tup)
tup = "I","r","o","n","h","a","c","k",
tup = tuple(tup)
tup

Tuples are immutable but we can:
1. Convert the tuple to a list
2. Reasign values (edit content)
3. Convert list back into a tuple
This works because they are same length.
It's the same as just overwriting the tuple.

Challenge 2:

  1. What is the relationship among the following values:
    len(set1) == ( len(set3) + len(set5) )
    Aquí te pedía relaciones entre los sets. Te dejo un ejemplo. Si lo ejecutas te tendría que salir True:) En tu caso: set1(80) = set3(38) + set5(42)

  2. Check if set1 contains set2 using the Python Set issubset method. Then check if set1 contains set3.*

print(set2.issubset(set1))
print(set3.issubset(set1))

Ojo! Lo has hecho al revés.

  1. Using the pop method, remove the first element from set1.
set1_list = list(set1)
set1_list.pop(0)
set1_list_pop = set(set1_list)  # And we convert it back to a set
print(set1_list_pop)

The pop method removes an element randomly, thus we could convert it to list to pop the first element.

  1. Remove every element in the following list from set1 if they are present in the set. Print the remaining elements.
remaining_elem = []
list_to_remove = [1, 9, 11, 19, 21, 29, 31, 39, 41, 49, 51, 59, 61, 69, 71, 79, 81, 89, 91, 99]

for i in set1:
    if i not in list_to_remove:
        remaining_elem.append(i)
print(remaining_elem)

✨Challenge 3: Impecable, nada a añadir.

sigue así!!! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants