Skip to content

lab-dict-sets-tuple - #18

Open
Estherkii wants to merge 2 commits into
Ironhack-data-bcn-oct-2023:mainfrom
IronLabWorks:main
Open

Estherkii wants to merge 2 commits into
Ironhack-data-bcn-oct-2023:mainfrom
IronLabWorks:main

Conversation

@Estherkii

Copy link
Copy Markdown

No description provided.

@bripollc

Copy link
Copy Markdown

Hola Esther,

Felicidades por tu segundo lab!!!!!!! Nadie dijo que fuera fácil. Te dejo a continuación las correcciones.

Challenge 1:

  1. Count the number of elements in tup1 and tup2. Then add the two counts together and check if the sum is the same as the number of elements in tup3.
sum1 = len(tup1)
sum2 = len(tup2)
sum12 = sum1 + sum2
print(sum12)

sum3 = len(tup3)
print(sum3)

En tu código, estas imprimiendo la longitud del tup1 (4) y el tup 2 (4) por separado. Te pide que los sumes, por lo que debes añadir un contador que sume la longitud de ambos tups para que te de 8. Entonces si será igual a la longitud de la tup3, que también es 8.

Challenge 2:

  1. In the cell below, create a list named sample_list_1 with 80 random values.
sample_list_1 = random.sample(range(100), k=80)
print(sample_list_1)

Has usado random.uniform(a, b) por lo que te genera una lista de valores aloatorios con floats. En el enunciado especifica que deben ser integers por lo deberías usar random.sample(a, b) .
Al haber puesto floats, los siguientes ejercicios del lab relacionados están bien planteado a nivel de código pero los resultados no son correctos. 🫠

  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.

Challenge 3: todo correcto, está perfecto!

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