forked from mouredev/retos-programacion-2023
-
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.
- Loading branch information
Showing
3 changed files
with
98 additions
and
2 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
76 changes: 76 additions & 0 deletions
76
Retos/Reto #35 - PRIMEROS PASOS [Fácil]/python/mouredev.py
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,76 @@ | ||
# Hola mundo | ||
print("¡Hola, Python!") | ||
|
||
# Variables | ||
my_variable = "Esto es una variable" | ||
my_variable = "Aquí asigno un nuevo valor a la variables" | ||
|
||
# Tipos de datos primitivos | ||
my_string: str = "Mi cadena de texto" | ||
my_int: int = 1 | ||
my_float: float = 1.5 | ||
my_bool: bool = True | ||
|
||
# Constantes | ||
MY_CONSTANT = "No existen las constantes. Simplemente se nombran variables en mayúscula." | ||
|
||
# Control de flujo | ||
if my_int == 1: | ||
print("my_int vale 1") | ||
elif my_int == 2: | ||
print("my_int vale 2") | ||
else: | ||
print("my_int no vale ni 1 ni 2") | ||
|
||
# Estructuras | ||
my_list: list = [my_string, my_int, my_float, my_bool] | ||
my_tuple: tuple = (my_string, my_int, my_float, my_bool) | ||
my_set: set = set([my_string, my_int, my_float, my_bool, my_string]) | ||
my_dictionary: dict = {"str": my_string, "int": my_int, "float": my_float, "bool": my_bool} | ||
|
||
# Bucles | ||
for index in range(10): | ||
print(index) | ||
|
||
for item in my_list: | ||
print(item) | ||
|
||
index = 0 | ||
while index < len(my_list): | ||
print(my_list[index]) | ||
index += 1 | ||
|
||
# Funciones | ||
def my_function(): | ||
print("Función simple") | ||
|
||
def my_function_with_return() -> str: | ||
return "Función con retorno" | ||
|
||
def my_function_with_parm(param: int): | ||
print(f"Función con un parámetro de valor {param}") | ||
|
||
my_function() | ||
print(my_function_with_return()) | ||
my_function_with_parm(256) | ||
|
||
# Clases | ||
class MyClass(): | ||
|
||
def __init__(self, name): | ||
self.name = name | ||
|
||
def hello(self): | ||
print(f"¡Hola, {self.name}!") | ||
|
||
my_class = MyClass("MoureDev") | ||
print(my_class.name) | ||
my_class.hello() | ||
|
||
# Excepciones | ||
try: | ||
print(0 / 0) | ||
except: | ||
print("Se ha producido una excepción") | ||
finally: | ||
print("Siempre se ejecuta el finally") |
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,19 @@ | ||
# Reto #36: Permutaciones | ||
#### Dificultad: Media | Publicación: 04/09/23 | Corrección: 18/09/23 | ||
|
||
## Enunciado | ||
|
||
``` | ||
/* | ||
* Crea un programa que sea capaz de generar e imprimir todas las | ||
* permutaciones disponibles formadas por las letras de una palabra. | ||
* - Las palabras generadas no tienen por qué existir. | ||
* - Deben usarse todas las letras en cada permutación. | ||
* - Ejemplo: sol, slo, ols, osl, los, lso | ||
*/ | ||
``` | ||
#### Tienes toda la información extendida sobre los retos de programación semanales en **[retosdeprogramacion.com/semanales2023](https://retosdeprogramacion.com/semanales2023)**. | ||
|
||
Sigue las **[instrucciones](../../README.md)**, consulta las correcciones y aporta la tuya propia utilizando el lenguaje de programación que quieras. | ||
|
||
> Recuerda que cada semana se publica un nuevo ejercicio y se corrige el de la semana anterior en directo desde **[Twitch](https://twitch.tv/mouredev)**. Tienes el horario en la sección "eventos" del servidor de **[Discord](https://discord.gg/mouredev)**. |