DEV Community

Cristian Fernando
Cristian Fernando

Posted on • Edited on

1

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

Explica este código Python

Dificultad: Básico

## Reto #29
def maximo(ls):
  return max(ls)

print(maximo(["a", "b", "c"]))
Enter fullscreen mode Exit fullscreen mode
  • A. a
  • B. b
  • C. c
  • D. None

Respuesta en el primer comentario.

Top comments (1)

Collapse
 
duxtech profile image
Cristian Fernando • Edited

Respuesta:

  • C. c

La función max() de Python como su nombre lo indica regresa el valor máximo de un iterable que le pasemos como argumento.

En este caso debemos encontrar el máximo de una lista de strings, entonces lo que hace Python es convertir de manera implícita los strings a su respectivo código ASCII:

Entonces tenemos algo como esto:

def maximo(ls):
  return max(ls)

print(maximo([97, 98, 99])) # a->97, b->98, c->99
Enter fullscreen mode Exit fullscreen mode

Ahora si es mucho más fácil saber por que la respuesta es c.

Image of Datadog

Create and maintain end-to-end frontend tests

Learn best practices on creating frontend tests, testing on-premise apps, integrating tests into your CI/CD pipeline, and using Datadog’s testing tunnel.

Download The Guide

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay