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.

👋 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