Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cd1d71a

Browse files
committed
Día 4
1 parent 48bf3bd commit cd1d71a

File tree

3 files changed

+137
-3
lines changed

3 files changed

+137
-3
lines changed

06_sets.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Clase 4 (24/08/22) en directo desde Twitch: https://www.twitch.tv/videos/1571410092
2+
3+
### Sets ###
4+
5+
# Definición
6+
7+
my_set = set()
8+
my_other_set = {}
9+
10+
print(type(my_set))
11+
print(type(my_other_set)) # Inicialmente es un diccionario
12+
13+
my_other_set = {"Brais","Moure", 35}
14+
print(type(my_other_set))
15+
16+
print(len(my_other_set))
17+
18+
# Inserción
19+
20+
my_other_set.add("MoureDev")
21+
22+
print(my_other_set) # Un set no es una estructura ordenada
23+
24+
my_other_set.add("MoureDev") # Un set no admite repetidos
25+
26+
print(my_other_set)
27+
28+
# Búsqueda
29+
30+
print("Moure" in my_other_set)
31+
print("Mouri" in my_other_set)
32+
33+
# Eliminación
34+
35+
my_other_set.remove("Moure")
36+
print(my_other_set)
37+
38+
my_other_set.clear()
39+
print(len(my_other_set))
40+
41+
del my_other_set
42+
#print(my_other_set) NameError: name 'my_other_set' is not defined
43+
44+
# Transformación
45+
46+
my_set = {"Brais","Moure", 35}
47+
my_list = list(my_set)
48+
print(my_list)
49+
print(my_list[0])
50+
51+
my_other_set = {"Kotlin","Swift", "Python"}
52+
53+
# Otras operaciones
54+
55+
my_new_set = my_set.union(my_other_set)
56+
print(my_new_set.union(my_new_set).union(my_set).union({"JavaScript", "C#"}))
57+
print(my_new_set.difference(my_set))

07_dicts.py

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Clase 4 (24/08/22) en directo desde Twitch: https://www.twitch.tv/videos/1571410092
2+
3+
### Dictionaries ###
4+
5+
# Definición
6+
7+
my_dict = dict()
8+
my_other_dict = {}
9+
10+
print(type(my_dict))
11+
print(type(my_other_dict))
12+
13+
my_other_dict = {"Nombre":"Brais", "Apellido":"Moure", "Edad":35, 1:"Python"}
14+
15+
my_dict = {
16+
"Nombre":"Brais",
17+
"Apellido":"Moure",
18+
"Edad":35,
19+
"Lenguajes": {"Python","Swift", "Kotlin"},
20+
1:1.77
21+
}
22+
23+
print(my_other_dict)
24+
print(my_dict)
25+
26+
print(len(my_other_dict))
27+
print(len(my_dict))
28+
29+
# Búsqueda
30+
31+
print(my_dict[1])
32+
print(my_dict["Nombre"])
33+
34+
print("Moure" in my_dict)
35+
print("Apellido" in my_dict)
36+
37+
# Inserción
38+
39+
my_dict["Calle"] = "Calle MoureDev"
40+
print(my_dict)
41+
42+
# Actualización
43+
44+
my_dict["Nombre"] = "Pedro"
45+
print(my_dict["Nombre"])
46+
47+
# Eliminación
48+
49+
del my_dict["Calle"]
50+
print(my_dict)
51+
52+
# Otras operaciones
53+
54+
print(my_dict.items())
55+
print(my_dict.keys())
56+
print(my_dict.values())
57+
58+
my_list = ["Nombre", 1, "Piso"]
59+
60+
my_new_dict = dict.fromkeys((my_list))
61+
print(my_new_dict)
62+
my_new_dict = dict.fromkeys(("Nombre", 1, "Piso"))
63+
print((my_new_dict))
64+
my_new_dict = dict.fromkeys(my_dict)
65+
print((my_new_dict))
66+
my_new_dict = dict.fromkeys(my_dict, "MoureDev")
67+
print((my_new_dict))
68+
69+
my_values = my_new_dict.values()
70+
print(type(my_values))
71+
72+
print(my_new_dict.values())
73+
print(list(dict.fromkeys(list(my_new_dict.values())).keys()))
74+
print(tuple(my_new_dict))
75+
print(set(my_new_dict))

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
#####Si consideras útil esta actividad, apóyala haciendo "★ Star" en el repositorio. ¡Gracias!
99

1010
> ---
11-
> **🔴 PRÓXIMA CLASE: Miércoles 24 de Agosto a las 20:00 (hora España)**
11+
> **🔴 PRÓXIMA CLASE: Miércoles 31 de Agosto a las 20:00 (hora España)**
1212
>
13-
> En [Discord](https://discord.gg/adD2PyFq?event=1009762258773082182) tienes creado un evento para que consultes la hora de tu país y añadas un recordatorio.
13+
> En [Discord](https://discord.gg/B4SGGAQqKZ?event=1012325339160125491) tienes creado un evento para que consultes la hora de tu país y añadas un recordatorio.
1414
>
1515
> *Finalizada la clase, se actualizará el repositorio con los nuevos recursos*
1616
>
@@ -23,6 +23,8 @@
2323
* Operadores y Strings.
2424
* Clase 3 (17/08/22): [Vídeo en Twitch con la clase completa](https://www.twitch.tv/videos/1564719056)
2525
* Listas y tuplas.
26+
* Clase 4 (24/08/22): [Vídeo en Twitch con la clase completa](https://www.twitch.tv/videos/1571410092)
27+
* Sets y diccionarios.
2628

2729
---
2830

@@ -70,7 +72,7 @@ Si quieres unirte a nuestra comunidad de desarrollo, aprender programación de A
7072
[![Discord](https://img.shields.io/discord/729672926432985098?style=social&label=Discord&logo=discord)](https://mouredev.com/discord)
7173
[![Twitter Follow](https://img.shields.io/twitter/follow/mouredev?style=social)](https://twitter.com/mouredev)
7274
![GitHub Followers](https://img.shields.io/github/followers/mouredev?style=social)
73-
![GitHub Followers](https://img.shields.io/github/stars/mouredev?style=social)
75+
![GitHub Followers](https://img.shields.io/github/stars/mouredev?style=social)
7476

7577
Soy ingeniero de software desde hace más de 12 años. Desde hace 4 años combino mi trabajo desarrollando Apps con creación de contenido formativo sobre programación y tecnología en diferentes redes sociales como **[@mouredev](https://moure.dev)**.
7678

0 commit comments

Comments
 (0)