Python Dasar-dasarMudah

Angka Positif atau Negatif

Panduan terperinci dan implementasi Python untuk soal 'Bilangan Positif atau Negatif'.

Pernyataan Masalah

Mudah

Tulis fungsi check_sign(n) yang mengambil bilangan bulat n dan mengembalikan string "Positive" jika n lebih besar dari nol, "Negative" jika n kurang dari nol, atau "Zero" jika n tepat nol.

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

Contoh

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?
Pertimbangkan untuk menggunakan struktur data khusus Dasar-Dasar seperti kumpulan atau tumpukan.
Edge Cases to Watch
  • Struktur masukan kosong
  • Masukan elemen tunggal
  • Batasan angka yang besar

Siap Memecahkannya?

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

Buka di 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

Sumber Daya Python yang Direkomendasikan

Perluas pengetahuan Anda dengan tutorial interaktif terkait, lembar contekan, dan perbandingan kode.