-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:IES-Rafael-Alberti/dam1-2425-ejerci…
…cios-u2-dcsibon
- Loading branch information
Showing
4 changed files
with
227 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
|
||
|
||
|
||
|
||
|
||
def main(): | ||
mi_lista = ["a", "b", "c"] | ||
mi_tupla = ("x", "y", "z") | ||
mi_conjunto = {"perro", "gato", "loro"} | ||
mi_diccionario = {"clave1": "valor1", "clave2": "valor2"} | ||
|
||
print(id(mi_conjunto)) | ||
|
||
return | ||
|
||
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
|
||
import os | ||
|
||
|
||
def limpiar_pantalla(): | ||
""" | ||
Limpia la consola según el sistema operativo. | ||
""" | ||
os.system('clear' if os.name == 'posix' else 'cls') | ||
|
||
|
||
def pausa(): | ||
""" | ||
Pausa la ejecución del programa hasta que se pulse ENTER. | ||
""" | ||
input("\nPresione ENTER para continuar...") | ||
limpiar_pantalla() | ||
|
||
|
||
def main(): | ||
asignaturas = ["Mates", "Lengua", "Inglés", "Física", "Química", "Historia"] | ||
|
||
limpiar_pantalla() | ||
|
||
print(asignaturas) | ||
|
||
pausa() | ||
|
||
for asignatura in asignaturas: | ||
print(asignatura) | ||
|
||
pausa() | ||
|
||
for i in range(len(asignaturas)): | ||
if i < len(asignaturas) - 1: | ||
print(asignaturas[i], end = " - ") | ||
else: | ||
print(asignaturas[i] + ".") | ||
|
||
pausa() | ||
|
||
pos = 0 | ||
frase = "" | ||
while pos < len(asignaturas): | ||
frase += asignaturas[pos] + ", " | ||
pos += 1 | ||
print(frase[:-2] + '.') | ||
|
||
pausa() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters