Python Nozioni di baseFacile

Numero positivo o negativo

Guida dettagliata e implementazione Python per il problema del "numero positivo o negativo".

Dichiarazione del problema

Facile

Scrivi una funzione check_sign(n) che accetta un numero intero n e restituisce la stringa "Positive" se n è maggiore di zero, "Negative" se n è inferiore a zero o "Zero" se n è esattamente zero.

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

Esempi

Example 1
Input
n = 5
Output
"Positive"
Explanation

5 is greater than 0, so we return "Positive".

Example 2
Input
n = -3
Output
"Negative"
Explanation

-3 is less than 0, so we return "Negative".

Example 3
Input
n = 0
Output
"Zero"
Explanation

0 is neither positive nor negative, so we return "Zero".

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.