Skip to content · ⁨ข้ามไปยังเนื้อหา⁩

Positive, negative or zero · ⁨บวก ลบ หรือศูนย์⁩

English

Positive, negative or zero

n is -4. Print positive, negative or zero — whichever n is.

Three answers need if, then elif, then else. Python tries them in order and stops at the first one that is true, so the else only runs when both questions above it said no.

ไทย

บวก ลบ หรือศูนย์

n คือ -4. พิมพ์ positive, negative หรือ zero — ขึ้นอยู่กับว่า n เป็นอะไร

คำตอบที่ถูกต้องมี if, ตามด้วย elif, แล้วจึง else. Python จะตรวจสอบตาม ลำดับ และหยุดที่เงื่อนไขแรกที่เป็นจริง ดังนั้น else จึงจะทำงานก็ต่อเมื่อคำถามทั้งสองข้อข้างต้นตอบว่า 'ไม่' เท่านั้น

Log in or create account · ⁨เข้าสู่ระบบหรือสร้างบัญชี⁩

IGCSE, A-Level & AP