DEV Community

Cristian Fernando
Cristian Fernando

Posted on

Ibuprofeno.py💊| #144: Explica este código Python

Explica este código Python

Dificultad: Fácil

for i in range(1):
    for j in range(1):
        print(i,j)
Enter fullscreen mode Exit fullscreen mode
  • A. 0, 0
  • B. 0, 1
  • C. 1, 1
  • D. Ninguna de las anteriores

Respuesta:

👉 A. 0, 0

Si solo pasamos un parámetro a la función range() este se considera como el limite del intervalo que queremos crear.

Por ejemplo si hacemos range(5) es lo mismo que escribir range(0, 5) por lo que la salida será: 0, 1, 2, 3, 4.

Entonces en nuestro ejemplo range(1) es lo mismo que decir range(0, 1) por lo que salida será: 0.

Por lo tanto, ambos range(1) solo iteraran sobre el valor 0 siendo la salida: 0, 0.

Top comments (0)

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay