Skip to content

Commit

Permalink
Pruebas fáciles con listas, tuplas, conjuntos y diccionarios.
Browse files Browse the repository at this point in the history
  • Loading branch information
dcsibon committed Nov 15, 2024
1 parent 79f2e04 commit ab11df9
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions pruebas/dam1_dic_set.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@





def main():
mi_lista = ["a", "b", "c"]
mi_tupla = ("x", "y", "z")
mi_conjunto = {"perro", "gato", "loro"}
mi_diccionario = {"clave1": "valor1", "clave2": "valor2"}

print(", ".join(mi_lista)) # "a, b, c"
print(" | ".join(mi_tupla)) # "x | y | z"
print(" - ".join(mi_conjunto)) # "perro - gato - loro" (orden no garantizado)
print(", ".join(mi_diccionario)) # "clave1, clave2"
print(", ".join(f"{k}:{v}" for k, v in mi_diccionario.items())) # "clave1:valor1, clave2:valor2"
print(" - ".join(mi_diccionario.values()))

return

mi_lista = ["uno", 2, "tres"]
resultado = ", ".join(map(str, mi_lista))
print(resultado)

a = set(range(1, 11))
a.update([100, 101, 33, 4])
print(a)

a.add(25)
a.add(33)

for e in a:
print(e, end=" ")

print()

while len(a) > 0:
print(a.pop())

return

d = {'uno': 1, 'dos': 2, 'tres': 3}
print(list(d))
print(list(d.keys()))
print(list(d.values()))
print(list(d.items()))

d.update([('cuatro', 4), ('cinco', 5)])
print(list(d.items()))






if __name__ == "__main__":
main()
File renamed without changes.

0 comments on commit ab11df9

Please sign in to comment.