Python Nozioni di baseFacile

Numero pari o dispari

Guida dettagliata e implementazione Python per il problema dei "numeri pari o dispari".

Dichiarazione del problema

Facile

Scrivi una funzione even_or_odd(n) che accetta un numero intero n e restituisce la stringa "Even" se n è divisibile per 2, o "Odd" altrimenti.

Vincoli
  • -10^9 <= n <= 10^9

Esempi

Example 1
Input
n = 4
Output
"Even"
Explanation

4 % 2 == 0, so 4 is even.

Example 2
Input
n = 7
Output
"Odd"
Explanation

7 % 2 == 1, so 7 is odd.

Example 3
Input
n = 0
Output
"Even"
Explanation

0 % 2 == 0, so 0 is even.

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.