Muestra las diferencias entre dos versiones de la página.
Ambos lados, revisión anteriorRevisión previaPróxima revisión | Revisión previa | ||
modelado:introduccion_python [2024/02/01 08:04] – thejuanvisu | modelado:introduccion_python [2024/02/01 08:39] (actual) – thejuanvisu | ||
---|---|---|---|
Línea 7: | Línea 7: | ||
variable = " | variable = " | ||
numero = 1 | numero = 1 | ||
+ | |||
+ | #Para saber el tipo de dato de una variable usamos type: | ||
+ | print(type(variable), | ||
</ | </ | ||
Línea 18: | Línea 21: | ||
De2en2 = [x fo x in range(0, | De2en2 = [x fo x in range(0, | ||
# | # | ||
+ | |||
+ | </ | ||
+ | |||
+ | Para el manejo de los array tenemos los siguientes ejemplos: | ||
+ | <code python> | ||
+ | array = [x for x in range (0, | ||
+ | size = len(array) #Obtenemos el tamaño del array | ||
+ | |||
+ | print(array[: | ||
+ | print(array[-10: | ||
+ | print(array[5: | ||
+ | print(array[85: | ||
+ | |||
+ | for value in array[:: | ||
+ | print(value) | ||
</ | </ | ||
Línea 66: | Línea 84: | ||
print(x) | print(x) | ||
</ | </ | ||
+ | |||
+ | ===== Bucle While ===== | ||
+ | |||
+ | <code python> | ||
+ | y = true | ||
+ | while(y): | ||
+ | print(1) | ||
+ | y=False | ||
+ | </ | ||
+ | |||
===== Funciones ===== | ===== Funciones ===== | ||
Línea 71: | Línea 99: | ||
<code python> | <code python> | ||
- | def funcion(parametroA, | + | #Sin definir tipos de datos que recibe y devuelve: |
+ | def funcion(parametroA, | ||
a = " | a = " | ||
print(" | print(" | ||
return a | return a | ||
+ | | ||
+ | #Definiendo el tipo de datos que debe recibir y devolver: | ||
+ | def nombre(par_1: | ||
+ | print(type(par_1)) | ||
+ | return par_1, par_2 | ||
</ | </ | ||
Línea 82: | Línea 116: | ||
return 1,2 | return 1,2 | ||
</ | </ | ||
+ | |||
+ | |||
+ | ===== Diccionarios en Python ===== | ||
+ | Se utilizan para almacenar datos. | ||
+ | <code python> | ||
+ | dicc = dict{ | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | |||
+ | print(dicc)# | ||
+ | |||
+ | #Para recorrer las claves del diccionario: | ||
+ | for key, value in dicc.items(): | ||
+ | print(f" | ||
+ | |||
+ | |||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | |||