Skip to content

Commit

Permalink
deploy: cfc58b6
Browse files Browse the repository at this point in the history
  • Loading branch information
sujith-rek committed Aug 28, 2023
1 parent c7271aa commit cf4874f
Show file tree
Hide file tree
Showing 1,357 changed files with 619,454 additions and 0 deletions.
Binary file added 292/BlueBar1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 292/Chinook_Sqlite.sqlite
Binary file not shown.
1 change: 1 addition & 0 deletions 292/NR
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
292
1 change: 1 addition & 0 deletions 292/REPO
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sujith-rek/PyZombis
Binary file added 292/_images/TWP05_015.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 292/_images/TWP05_035.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 292/_images/TWP05_041.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 292/_images/TWP10_001.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 292/_images/TWP10_002.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 292/_images/TWP10_004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 292/_images/TWP10_009.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 292/_images/TWP10_011.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 292/_images/TWP15_001.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 292/_images/TWP15_002.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 292/_images/TWP15_007.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 292/_images/TWP15_007.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 292/_images/TWP17_004.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 292/_images/TWP17_005.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 292/_images/TWP17_006.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 292/_images/TWP17_007.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 292/_images/TWP18_015.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 292/_images/TWP18_016.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 292/_images/TWP18_017.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 292/_images/TWP18_018.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 292/_images/TWP30_001.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 292/_images/TWP30_002.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 292/_images/TWP30_004.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 292/_images/TWP30_005.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 292/_images/TWP30_006.jpg
Binary file added 292/_images/TWP30_009.jpg
Binary file added 292/_images/TWP30_0092.jpg
Binary file added 292/_images/TWP30_012.jpg
Binary file added 292/_images/TWP33_001.jpg
Binary file added 292/_images/TWP33_004.jpg
Binary file added 292/_images/TWP33_005.png
Binary file added 292/_images/TWP33_006.png
Binary file added 292/_images/TWP33_007.jpg
Binary file added 292/_images/TWP33_008.jpg
Binary file added 292/_images/TWP33_009.jpg
Binary file added 292/_images/TWP33_012.jpg
Binary file added 292/_images/TWP33_015.jpg
Binary file added 292/_images/TWP33_016.jpg
Binary file added 292/_images/TWP33_018.jpg
Binary file added 292/_images/TWP33_025.jpg
Binary file added 292/_images/TWP33_028.jpg
Binary file added 292/_images/TWP33_029.jpg
Binary file added 292/_images/TWP33_030.jpg
Binary file added 292/_images/TWP33_032.jpg
Binary file added 292/_images/TWP33_033.jpg
Binary file added 292/_images/TWP33_034.jpg
Binary file added 292/_images/TWP35_001.jpeg
Binary file added 292/_images/TWP35_002.jpeg
Binary file added 292/_images/TWP35_005.jpeg
Binary file added 292/_images/TWP37_001.jpeg
Binary file added 292/_images/TWP37_002.jpeg
Binary file added 292/_images/TWP37_003.jpeg
Binary file added 292/_images/TWP37_004.jpg
Binary file added 292/_images/TWP37_007.jpg
Binary file added 292/_images/TWP37_008.jpg
Binary file added 292/_images/TWP37_010.jpg
Binary file added 292/_images/TWP37_011.jpg
Binary file added 292/_images/TWP37_014.jpg
Binary file added 292/_images/TWP37_016.jpg
Binary file added 292/_images/TWP37_017.jpg
Binary file added 292/_images/TWP37_018.jpg
Binary file added 292/_images/TWP37_021.jpg
Binary file added 292/_images/TWP37_022.jpg
Binary file added 292/_images/TWP37_025.jpg
Binary file added 292/_images/TWP37_026.png
Binary file added 292/_images/TWP37_027.png
Binary file added 292/_images/TWP42_003.jpeg
Binary file added 292/_images/TWP42_004.jpeg
Binary file added 292/_images/TWP42_005.jpeg
Binary file added 292/_images/TWP42_009.png
Binary file added 292/_images/TWP45_001.jpeg
Binary file added 292/_images/TWP45_002.jpeg
Binary file added 292/_images/TWP45_050.png
Binary file added 292/_images/TWP47_001.png
Binary file added 292/_images/TWP47_002.png
Binary file added 292/_images/TWP47_004.jpg
Binary file added 292/_images/TWP47_005.png
Binary file added 292/_images/TWP47_006.png
Binary file added 292/_images/TWP47_007.png
Binary file added 292/_images/TWP47_008.jpg
Binary file added 292/_images/TWP47_011.jpg
Binary file added 292/_images/TWP47_015.png
Binary file added 292/_images/TWP47_017.png
Binary file added 292/_images/TWP47_018.png
Binary file added 292/_images/TWP47_020.png
Binary file added 292/_images/TWP47_021.png
Binary file added 292/_images/TWP50_003.png
Binary file added 292/_images/TWP50_004.png
Binary file added 292/_images/TWP50_006.png
Binary file added 292/_images/TWP50_007.jpg
Binary file added 292/_images/TWP50_008.jpg
Binary file added 292/_images/TWP50_013.jpg
Binary file added 292/_images/TWP50_017.jpg
Binary file added 292/_images/TWP52_001.jpg
Binary file added 292/_images/TWP52_005.jpg
Binary file added 292/_images/TWP52_006.jpg
Binary file added 292/_images/TWP52_007.png
Binary file added 292/_images/TWP52_008.jpg
Binary file added 292/_images/TWP52_009.jpg
Binary file added 292/_images/TWP52_013.jpg
Binary file added 292/_images/TWP52_014.png
Binary file added 292/_images/TWP52_016.jpg
Binary file added 292/_images/TWP52_017.png
Binary file added 292/_images/TWP52_020.jpg
Binary file added 292/_images/TWP54_001.jpg
Binary file added 292/_images/TWP54_002.jpg
Binary file added 292/_images/TWP54_003.jpg
Binary file added 292/_images/TWP54_004.jpg
Binary file added 292/_images/TWP54_005.jpg
Binary file added 292/_images/TWP54_007.jpg
Binary file added 292/_images/TWP54_009.jpg
Binary file added 292/_images/TWP54_010.jpg
Binary file added 292/_images/TWP56_001.jpg
Binary file added 292/_images/TWP56_003.jpg
Binary file added 292/_images/TWP56_005.jpg
Binary file added 292/_images/TWP56_008.jpg
Binary file added 292/_images/TWP56_010.jpg
Binary file added 292/_images/TWP58_002.jpeg
Binary file added 292/_images/TWP58_003.jpg
Binary file added 292/_images/TWP58_004.jpg
Binary file added 292/_images/TWP58_005.jpg
Binary file added 292/_images/TWP58_006.jpg
Binary file added 292/_images/TWP58_007.jpg
Binary file added 292/_images/TWP58_010.png
Binary file added 292/_images/TWP58_011.png
Binary file added 292/_images/TWP60_001.jpeg
Binary file added 292/_images/TWP60_002.jpeg
Binary file added 292/_images/TWP60_005.png
Binary file added 292/_images/TWP60_007.png
Binary file added 292/_images/TWP60_008.png
Binary file added 292/_images/TWP60_014.png
Binary file added 292/_images/TWP60_015.png
Binary file added 292/_images/TWP60_017.png
Binary file added 292/_images/TWP60_022.png
Binary file added 292/_images/TWP60_023.png
Binary file added 292/_images/TWP65_001.jpg
Binary file added 292/_images/TWP65_002.jpg
340 changes: 340 additions & 0 deletions 292/_sources/challenges/Reto01.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,340 @@
=============
Reto Ahorcado
=============

Este reto consiste en crear el juego de **ahorcado** a partir de código Python.

.. tabbed:: ahorcado

.. tab:: Ejercicio 1

Primero haremos los distintos dibujos del ahorcado con cadenas de texto.

.. activecode:: ac_r01_1
:nocodelens:

En la lista ``dibujos`` colocaremos las cadenas de texto que representan
los dibujos del ahorcado.

~~~~
dibujos = [
"""
+------+
|
|
|
|
|
+--------+ """,
"""
+------+
| |
|
|
|
|
+--------+ """,
"""
+------+
| |
o |
|
|
|
+--------+ """,
"""
+------+
| |
o |
| |
|
|
+--------+ """,
"""
+------+
| |
o |
/| |
|
|
+--------+ """,
"""
+------+
| |
o |
/|\ |
|
|
+--------+ """,
"""
+------+
| |
o |
/|\ |
/ |
|
+--------+ """,
"""
+------+
| |
o |
/|\ |
/ \ |
|
+--------+ """,
]


.. tab:: Ejercicio 2

Va a resolver el reto de manera progresiva.

.. activecode:: ac_r01_2
:nocodelens:

Cree dos variables, una llamada ``correctas`` y la otra ``incorrectas``. Ambas asígnelas a
una cadena vacía.

~~~~

====
from unittest.gui import TestCaseGui


class myTests(TestCaseGui):
def testOne(self):

self.assertEqual(correctas, "", "Probando que correctas esté asignada correctamente")
self.assertEqual(incorrectas, "", "Probando que incorrectas esté asignada correctamente")


myTests().main()


.. tab:: Ejercicio 3

¿Recuerda la lección de las APIs? Vamos a aplicar lo aprendido de esa lección.

.. activecode:: ac_r01_3
:nocodelens:

Para poder jugar ahorcado necesitamos palabras para adivinar. En este caso vamos a
recuperar esas palabras de la API de University Domains. Estas palabras serán ciudades
del mundo.
Con la librería ``requests`` acceda a la API de University Domains. La url es la siguiente
http://universities.hipolabs.com/search
Desarrolle la función ``escoger`` que escoja de manera **aleatoria** una ciudad dentro de las ciudades de la
lista ``ciudades``. Esta ciudad será devuelta por la función. Cabe aclarar que el nombre de cada ciudad
está en inglés.

~~~~
import requests
import json
from random import choice

api_url = "http://universities.hipolabs.com/search"

solicitud = requests.get(api_url)
datos = json.loads(solicitud.text)

ciudades = []
for universidad in datos:
if universidad["country"] not in ciudades:
ciudades.append(universidad["country"].lower().replace(" ", ""))

def escoger(ciudades):
# Desarrolle la función
# Se puede lograr con una sola línea de código


====
from unittest.gui import TestCaseGui


class myTests(TestCaseGui):
def testOne(self):

self.assertEqual(str(type(escoger)), "<class 'function'>", "Probando que escoger haya sido definida")
self.assertEqual(escoger(["Mexico"]), "Mexico", "Probando que la función sirva")
self.assertEqual(choice([2]), 2, "Probando que choice haya sido importado")


myTests().main()


.. tab:: Ejercicio 4

Ahora definamos otra función para imprimir el ahorcado.

.. activecode:: ac_r01_4
:nocodelens:
:include: ac_r01_1, ac_r01_2, ac_r01_3

La función ``imprimir_ahorcado`` imprime el dibujo del ahorcado correspondiente al
número de letras incorrectas y correctas hasta el momento. Toma un único parámetro
``p_aleatoria`` que representa la palabra a adivinar.

~~~~
p_aleatoria = escoger(ciudades)
def imprimir_ahorcado(p_aleatoria):
print(dibujos[len(incorrectas)])
for c in p_aleatoria:
print(c if c in correctas else "_", end=" ")
print()


.. tab:: Ejercicio 5

Es momento de crear la función principal de nuestro programa, la cuál pide al usuario una
letra para adivinar.

.. activecode:: ac_r01_5
:nocodelens:

Desarrolle la función ``adivinar``. Recibe como parámetro una cadena (``letras``) con todas las letras ya
probadas (correctas + incorrectas). Devuelve una letra minúscula que no se ha probado antes.
Si el usuario ingresa más de una letra u otro carácter especial, se debe imprimir un mensaje
alertando al usuario de su error. Por ejemplo: ``"Caracter inválido"``
Esta función tendrá un bucle que hará que todos los datos sean coherentes y solo pasará
a tu programa principal la letra minúscula que no se probó antes. Guarde lo ingresado por el usuario en la
variable ``x``. **Nota**: La función se va a ejecutar una vez y pedirá que se ingrese una letra
para verificar si pasa las pruebas unitarias.

~~~~
from string import digits, punctuation
import time

def adivinar(letras):
while True:
x = # Empiece aquí

# Todo su código debe ir dentro de este ciclo while

# Esperar antes de preguntar por un input de nuevo
# No remover esta línea de código
time.sleep(2)


====
from unittest.gui import TestCaseGui
import string


class myTests(TestCaseGui):
def testOne(self):
x = adivinar("aeiou")
self.assertEqual(x in string.ascii_lowercase, True, "Probando que x haya sido devuelto correctamente")


myTests().main()


.. tab:: Ejercicio 6

Hagamos posible que el usuario decida si quiere volver a jugar o no.

.. activecode:: ac_r01_6
:nocodelens:

Desarrolle la función ``jugar_nuevamente`` que pregunte al usuario si quiere volver a
jugar. La respuesta debe ser una *s* o *n* (S/N). Sin importar si el usuario ingresa la respuesta
en mayúscula o minúscula, el programa debe transformarla a minúscula. La función devuelve ``True`` o ``False``
dependiendo de la respuesta. **Nota**: La función se va a ejecutar dos veces para verificar si pasa las pruebas unitarias.
En la consola verá instrucciones sobre qué ingresar para cada prueba.

~~~~
def jugar_nuevamente():

return


====
from unittest.gui import TestCaseGui
import time


class myTests(TestCaseGui):
def testOne(self):
print("Ingrese 'S'")
time.sleep(2)
r = jugar_nuevamente()
self.assertEqual(r, True, "Probando que se haya utilizado el método lower")


def testTwo(self):
print("Ingrese 'n'")
time.sleep(2)
r = jugar_nuevamente()
self.assertEqual(r, False, "Probando que al ingresar 'n' regrese False")


myTests().main()


.. tab:: Ejercicio 7

.. activecode:: ac_r01_7
:nocodelens:

Ahora desarrolle la función ``ganar``. Ésta toma dos parámetros: ``p_aleatoria`` que representa
la palabra a adivinar, y ``letras_adivinadas``. Debe devolver ``True`` si todas las letras de
``p_aleatoria`` están en la cadena ``letras_adivinadas``. De lo contrario, devuelve False.

~~~~
def ganar(p_aleatoria, letras_adivinadas):


====
from unittest.gui import TestCaseGui


class myTests(TestCaseGui):
def testOne(self):
self.assertEqual(ganar("argentina", "anitnegra"), True, "Probando la función")
self.assertEqual(ganar("argentina", "argent"), False, "Probando la función")


myTests().main()

.. tab:: Ejercicio 8

Ya ha definido todas las funciones y variables necesarias para el programa. Si ha llegado hasta aquí,
debió haber cumplido con todo y haber pasado todas las pruebas unitarias. De ser así, puede correr el
siguiente programa para probar su juego. El tiempo que tiene para jugar son 5 minutos.

.. activecode:: ac_r01_8
:nocodelens:
:include: ac_r01_1, ac_r01_2, ac_r01_3, ac_r01_4, ac_r01_5, ac_r01_6, ac_r01_7

# Esto nos sirve para aumentar la duración del programa a 5 minutos.
import sys
sys.setExecutionLimit(300000)

p_aleatoria = escoger(ciudades)

while True:
imprimir_ahorcado(p_aleatoria)
time.sleep(2)
x = adivinar(correctas + incorrectas)
if x in p_aleatoria:
correctas = correctas + x
else:
incorrectas = incorrectas + x
if len(incorrectas) == len(dibujos):
print(f"Quedó ahorcado, la palabra era {p_aleatoria}")
time.sleep(1)
if jugar_nuevamente():
correctas = incorrectas = ""
p_aleatoria = escoger(ciudades)
else:
break
elif ganar(p_aleatoria, correctas):
print(f"Acertó la palabra: {p_aleatoria}")
time.sleep(1)
if jugar_nuevamente():
correctas = incorrectas = ""
p_aleatoria = escoger(ciudades)
else:
break

====
Loading

0 comments on commit cf4874f

Please sign in to comment.