-
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
0 parents
commit 48f5cc9
Showing
85 changed files
with
1,122 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
Binary file not shown.
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,11 @@ | ||
""" | ||
Bienvenido al día 80 de #100diasdepython | ||
El reto de hoy es: | ||
Utiliza itertools para repetir el numero 80 | ||
5 veces en una lista | ||
Imprime el resultado en una lista | ||
""" | ||
import itertools | ||
|
||
lista = list(itertools.repeat(80,5)) | ||
print (lista) |
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,13 @@ | ||
""" | ||
Bienvenido al día 81 de #100diasdepython | ||
El reto de hoy es: | ||
Utiliza datetime para agregarle a la | ||
fecha actual 7 dias más | ||
Imprime el resultado | ||
""" | ||
import datetime | ||
|
||
hoy = datetime.date(2022,7,9) | ||
dias = datetime.timedelta(days=7) | ||
fecha = hoy + dias | ||
print (fecha) |
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,11 @@ | ||
""" | ||
Bienvenido al día 82 de #100diasdepython | ||
El reto de hoy es: | ||
Utiliza datetime para imprimir la fecha y hora | ||
actual en el formato "10 July 2022, 12:12:12 AM" | ||
Imprime el resultado en una cadena | ||
""" | ||
import datetime | ||
|
||
ahora = datetime.datetime.now() | ||
print (ahora.strftime('%d %B %Y, %H:%M:%S %p')) |
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,12 @@ | ||
""" | ||
Bienvenido al día 83 de #100diasdepython | ||
El reto de hoy es: | ||
Utiliza datetime para convertir la fecha | ||
"Jul 11 2022 1:30AM" al formato | ||
"2022-07-11 01:30:00" | ||
Imprime el resultado | ||
""" | ||
from datetime import datetime | ||
|
||
fecha = datetime.strptime("Jul 11 2022 1:30AM","%b %d %Y %H:%M%p") | ||
print (fecha) |
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,14 @@ | ||
""" | ||
Bienvenido al día 84 de #100diasdepython | ||
El reto de hoy es: | ||
Utiliza datetime para convertir la cadena | ||
"12-07-2022" a timestamp | ||
Imprime el resultado | ||
""" | ||
from datetime import datetime | ||
import time | ||
|
||
cadena = "12-07-2022" | ||
fecha = datetime.strptime(cadena,"%d-%m-%Y") | ||
ts = time.mktime(fecha.timetuple()) | ||
print (ts) |
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,10 @@ | ||
""" | ||
Bienvenido al día 85 de #100diasdepython | ||
El reto de hoy es: | ||
Utiliza datetime para imprimir la fecha y | ||
hora actual en UTC | ||
""" | ||
from datetime import datetime | ||
|
||
fecha = datetime.utcnow() | ||
print (fecha) |
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,17 @@ | ||
""" | ||
Bienvenido al día 86 de #100diasdepython | ||
El reto de hoy es: | ||
Utiliza datetime para calcular la cantidad | ||
de segundos que han pasado desde el inicio | ||
del reto considerando solo la fecha | ||
Considera que el reto inicio el "20/04/2022" | ||
Imprime el resultado | ||
""" | ||
from datetime import datetime | ||
|
||
cadena = "20/04/2022" | ||
inicio = datetime.strptime(cadena, '%d/%m/%Y') | ||
hoy = datetime.now() | ||
delta = hoy - inicio | ||
segundos = delta.total_seconds() | ||
print (segundos) |
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,9 @@ | ||
""" | ||
Bienvenido al día 87 de #100diasdepython | ||
El reto de hoy es: | ||
Utiliza calendar para imprimir el mes de | ||
Julio en formato calendario | ||
""" | ||
import calendar | ||
|
||
print(calendar.month(2022, 7)) |
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,15 @@ | ||
""" | ||
Bienvenido al día 89 de #100diasdepython | ||
El reto de hoy es: | ||
Utiliza calendar para obtener los dias lunes | ||
del mes Julio del año 2022 | ||
Imprime el resultado en una lista | ||
""" | ||
import calendar | ||
|
||
c = calendar.TextCalendar(calendar.MONDAY) | ||
|
||
lista = [i for i in c.itermonthdays(2022,7)] | ||
lunes = [lista[x] for x in range (0,31,7) if x>0 ] | ||
|
||
print (lunes) |
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,13 @@ | ||
""" | ||
Bienvenido al día 90 de #100diasdepython | ||
El reto de hoy es: | ||
Utiliza datetime para imprimir la fecha y hora | ||
en formato de 12 horas ejemplo "2022/07/18 11:30 PM" | ||
Imprime el resultado en una cadena | ||
""" | ||
from datetime import datetime | ||
cadena = "2022/07/18 11:30 PM" | ||
|
||
fecha12 = datetime.strptime(cadena,"%Y/%m/%d %I:%M %p") | ||
fecha24 = fecha12.strftime("%Y/%m/%d %H:%M %p") | ||
print (fecha24) |
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,14 @@ | ||
""" | ||
Bienvenido al día 91 de #100diasdepython | ||
El reto de hoy es: | ||
Crea una funcion que devuelva los cuadrados | ||
de los primeros 10 numeros enteros iniciando en 1 | ||
utilizando yields | ||
Imprime el resultado en una Lista | ||
""" | ||
def cuadrados(num): | ||
for i in num: | ||
yield pow(i,2) | ||
|
||
lista = [x for x in cuadrados(range(1,11))] | ||
print (lista) |
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,22 @@ | ||
""" | ||
Bienvenido al día 92 de #100diasdepython | ||
El reto de hoy es: | ||
Crea una funcion que use yield y genere la | ||
siguiente serie [1, 2, 3, 2, 1, 2, 3, 2, 1] | ||
Imprime el resultado en una lista | ||
""" | ||
def serie(num): | ||
i = 1 | ||
x = 1 | ||
while x<=(num): | ||
if i<=3: | ||
yield i | ||
i+=1 | ||
x+=1 | ||
else: | ||
yield 2 | ||
i-=3 | ||
x+=1 | ||
|
||
lista = list(serie(9)) | ||
print (lista) |
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,17 @@ | ||
""" | ||
Bienvenido al día 93 de #100diasdepython | ||
El reto de hoy es: | ||
Crea una funcion que use yield y genere los primeros | ||
10 numeros de la serie de Fibonacci | ||
[1, 1, 2, 3, 5, 8, 13, 21, 34, 55] | ||
Imprime el resultado en una lista | ||
""" | ||
|
||
def fib(n): | ||
a, b = 1, 1 | ||
for _ in range(n): | ||
yield a | ||
a, b = b, a + b | ||
|
||
lista =list(fib(10)) | ||
print (lista) |
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,14 @@ | ||
""" | ||
Bienvenido al día 94 de #100diasdepython | ||
El reto de hoy es: | ||
Crea una funcion que use argumentos arbitrarios | ||
para recibir N-cadenas de nombres y | ||
devuelva una lista de N-saludos | ||
ejemplo de salida ['Hola Katy', 'Hola Ariel'] | ||
Imprime el resultado en una Lista | ||
""" | ||
def saludo(*nombres): | ||
lista = [f'Hola {i}' for i in nombres] | ||
return lista | ||
|
||
print (saludo('Katy', 'Ariel')) |
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,15 @@ | ||
""" | ||
Bienvenido al día 95 de #100diasdepython | ||
El reto de hoy es: | ||
Crea una funcion que use argumentos arbitrarios | ||
para recibir N-números y determine en un diccionario | ||
en el siguiente formato {"mayor": 5, "menor": -10} | ||
Imprime el resultado | ||
""" | ||
def maxmin(*args): | ||
mayornum = max(args) | ||
menornum = min(args) | ||
resultado = {"mayor": mayornum, "menor": menornum} | ||
return resultado | ||
|
||
print (maxmin(-5, -10, 3, 0, 5, 1, 2)) |
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,14 @@ | ||
""" | ||
Bienvenido al día 96 de #100diasdepython | ||
El reto de hoy es: | ||
Crea una funcion que use argumentos arbitrarios de tipo | ||
Keyword para recibir nombre, apellido y edad y devuelva | ||
estos argumentos en un diccionario en el siguiente formato | ||
{"nombre": "Pepito", "apellido": "Perez", "edad": 25} | ||
Imprime el resultado | ||
""" | ||
def mifuncion(**kwargs): | ||
resultado = {"nombre": kwargs["firstname"], "apellido": kwargs["lastname"], "edad": kwargs["age"]} | ||
return resultado | ||
|
||
print(mifuncion(firstname= "Pepito", lastname= "Perez", age = 25)) |
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 @@ | ||
""" | ||
Bienvenido al día 98 de #100diasdepython | ||
El reto de hoy es: | ||
Utiliza timeit para obtener el tiempo de | ||
ejecución de la siguiente función | ||
Imprime el resultado en una sola línea | ||
""" | ||
import timeit | ||
|
||
miSetup = "print('Iniciamos...')" | ||
|
||
miCodigo = ''' | ||
def Lazy(): | ||
suma = 0 | ||
for i in range (0, 50000000): | ||
suma += i | ||
''' | ||
|
||
print (timeit.timeit(stmt=miCodigo, number=1)) |
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,12 @@ | ||
""" | ||
Bienvenido al día 99 de #100diasdepython | ||
El reto de hoy es: | ||
Utiliza try para capturar e imprimir la | ||
excepcion de una división entre 0 del siguiente | ||
fragmento de codigo | ||
""" | ||
try: | ||
a = 7 | ||
b = a/0 | ||
except ZeroDivisionError as valueError: | ||
print(valueError) |
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,22 @@ | ||
""" | ||
Bienvenido al día 100 de #100diasdepython | ||
El reto de hoy es: | ||
Utiliza try para capturar e imprimir la excepcion | ||
dentro de la siguiente función y agrega un mensaje | ||
final utilizando finally | ||
En este reto si se aceptan multiples print | ||
""" | ||
|
||
def dia100(): | ||
mensaje = "Llegaste al último día" | ||
print(mensaje[len(mensaje)]) | ||
|
||
try: | ||
dia100() | ||
except Exception as e: | ||
print("Error: {}".format(e)) | ||
finally: | ||
print("""Me encantó descubrir nuevas cosas de python a través de estos retos, | ||
100 días se pasaron volando | ||
voy a extrañar este grato hábito mañana :) | ||
Muchas gracias por su esfuerzo con la comunidad!!!""") |
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,8 @@ | ||
""" | ||
Bienvenido al día 16 de #100diasdepython | ||
El reto de hoy es: | ||
Declara una variable de tipo cadena e imprime la cantidad de | ||
caracteres de la cadena sin usar ciclos. | ||
""" | ||
cadena = "Python es Cool!" | ||
print(len(cadena)) |
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,9 @@ | ||
""" | ||
Bienvenido al día 17 de #100diasdepython | ||
El reto de hoy es: | ||
Declara una variable de tipo cadena, encuentra la cantidad | ||
de veces que aparece la letra 'a' | ||
sin usar ciclos e imprime el resultado | ||
""" | ||
cadena = 'Python es Genial!' | ||
print(cadena.count('a')) |
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,10 @@ | ||
""" | ||
Bienvenido al día 18 de #100diasdepython | ||
El reto de hoy es: | ||
Declara una variable de tipo cadena, encuentra el primer y último carácter | ||
en orden lexicográficosin usar ciclos e imprímelos | ||
""" | ||
cadena='Python tiene pureza' | ||
cadena=cadena.lower().replace(" ","") #homogenizamos los caracteres, no considero depuración de símbolos | ||
cadena=sorted(cadena) #convertimos en lista y ordenamos | ||
print(cadena[0],cadena[-1]) #imprimimos el primero y el último |
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,8 @@ | ||
""" | ||
Bienvenido al día 19 de #100diasdepython | ||
El reto de hoy es: | ||
Declara una variable de tipo cadena, reviértela sin usar | ||
funciones adicionales e imprime el resultado | ||
""" | ||
cadena = 'Python es Genial!' | ||
print (cadena[::-1]) |
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,11 @@ | ||
""" | ||
Bienvenido al día 20 de #100diasdepython | ||
El reto de hoy es: | ||
De la siguiente cadena: 'PpYyTtHhOoNnIiSsTtAa' | ||
Separa las mayusculas y las minúsculas sin usar ciclos en nuevas cadenas | ||
e imprime el resultado en una sola línea | ||
""" | ||
cadena='PpYyTtHhOoNnIiSsTtAa' | ||
mayus=cadena[:len(cadena):2] | ||
minus=cadena[1:len(cadena):2] | ||
print(mayus,minus) |
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,9 @@ | ||
""" | ||
Bienvenido al día 21 de #100diasdepython | ||
El reto de hoy es: | ||
Utiliza lo aprendido en el reto anterior para encontrar | ||
el mensaje escondido en: | ||
hjfacetiluzislcafiesdolavedfiedesno | ||
""" | ||
cadena='hjfacetiluzislcafiesdolavedfiedesno' | ||
print(cadena[2::3]) |
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,10 @@ | ||
""" | ||
Bienvenido al día 22 de #100diasdepython | ||
El reto de hoy es: | ||
Utiliza funciones de cadenas para crear una lista | ||
de palabras con la siguiente cadena: | ||
"Los pequeños pasos te llevan a algo más grande" | ||
""" | ||
cadena="Los pequeños pasos te llevan a algo más grande" | ||
lista=cadena.split() | ||
print (lista) |
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,11 @@ | ||
""" | ||
Bienvenido al día 23 de #100diasdepython | ||
El reto de hoy es: | ||
Utiliza funciones de cadenas para quitar los | ||
eapacios innecesarios de la siguiente cadena: | ||
" Python es divertido " | ||
""" | ||
cadena=" Python es divertido " | ||
#cadena=cadena.replace(" ","") # Esta fue mi versión | ||
cadena=cadena.strip() # Esta fue la requerida | ||
print(cadena) |
Oops, something went wrong.