Python Nozioni di baseFacile

Anno bisestile oppure no

Guida dettagliata e implementazione Python per il problema "Anno bisestile o no".

Dichiarazione del problema

Facile

Scrivi una funzione is_leap_year(year) che accetta un numero intero year e restituisce True se l'anno è bisestile, o False altrimenti. Un anno è bisestile se è divisibile per 4 ma non per 100, tranne quando è divisibile anche per 400.

Vincoli
  • 1 <= year <= 10^5

Esempi

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?
Prendi in considerazione l'utilizzo di strutture dati specifiche di Basics come set o heap.
Edge Cases to Watch
  • Strutture di input vuote
  • Ingressi a elemento singolo
  • Grandi limiti numerici

Pronto a risolvere?

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

Apri nell'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

Risorse Python consigliate

Espandi le tue conoscenze con tutorial interattivi, foglietti illustrativi e confronti di codici correlati.