Python Conceptos básicosfácil

Año bisiesto o no

Guía detallada e implementación de Python para el problema 'Año bisiesto o no'.

Declaración del problema

fácil

Escriba una función is_leap_year(year) que tome un número entero year y devuelva True si el año es bisiesto, o False en caso contrario. Un año es bisiesto si es divisible por 4 pero no por 100, excepto cuando también sea divisible por 400.

Restricciones
  • 1 <= year <= 10^5

Ejemplos

Example 1
Input
year = 2024
Output
True
Explanation

2024 is divisible by 4 and not by 100, so it is a leap year.

Example 2
Input
year = 1900
Output
False
Explanation

1900 is divisible by 100 but not by 400, so it is not a leap year.

Example 3
Input
year = 2000
Output
True
Explanation

2000 is divisible by 400, so it is a leap year.

Need a Hint?
Considere la posibilidad de utilizar estructuras de datos específicas de Basics, como conjuntos o montones.
Edge Cases to Watch
  • Estructuras de entrada vacías
  • Entradas de un solo elemento
  • Grandes límites numéricos

¿Listo para resolver?

Open the problem in PyRun's browser-based Python editor. Your code runs fully offline — no server required.

Abrir en el editor
Found this breakdown helpful?

PyRun is built and maintained by an independent solo developer. If this helped your interview prep, consider buying a coffee!

Buy me a coffee

Recursos recomendados de Python

Amplíe sus conocimientos con tutoriales interactivos relacionados, hojas de trucos y comparaciones de códigos.