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
4 changed files
with
61 additions
and
3 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,9 @@ | ||
import requests | ||
|
||
url = "https://pokeapi.co/api/v2/pokemon?limit=151" | ||
|
||
response = requests.get(url) | ||
|
||
for index, pokemon in enumerate(response.json()["results"]): | ||
pokemon_name = pokemon["name"] | ||
print(f"#{index + 1} {pokemon_name}") |
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,29 @@ | ||
import Foundation | ||
import PlaygroundSupport | ||
|
||
let page = PlaygroundPage.current | ||
page.needsIndefiniteExecution = true | ||
|
||
struct PokemonList: Decodable { | ||
let results: [Pokemon] | ||
} | ||
|
||
struct Pokemon: Decodable { | ||
let name: String | ||
} | ||
|
||
if let url = URL(string: "https://pokeapi.co/api/v2/pokemon?limit=151") { | ||
|
||
let request = URLRequest(url: url) | ||
let (data, response) = try await URLSession.shared.data(for: request) | ||
|
||
if (response as? HTTPURLResponse)?.statusCode == 200 { | ||
let pokemonList = try JSONDecoder().decode(PokemonList.self, from: data) | ||
for (index, pokemon) in pokemonList.results.enumerated() { | ||
let pokemonName = pokemon.name | ||
print("#\(index + 1) \(pokemonName)") | ||
} | ||
|
||
page.finishExecution() | ||
} | ||
} |
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 #11: URL params | ||
#### Dificultad: Fácil | Publicación: 13/03/23 | Corrección: 20/03/23 | ||
|
||
## Enunciado | ||
|
||
``` | ||
/* | ||
* Dada una URL con parámetros, crea una función que obtenga sus valores. | ||
* No se pueden usar operaciones del lenguaje que realicen esta tarea directamente. | ||
* | ||
* Ejemplo: En la url https://retosdeprogramacion.com?year=2023&challenge=0 | ||
* los parámetros serían ["2023", "0"] | ||
*/ | ||
``` | ||
#### 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)**. |