Positive, negative or zero · บวก ลบ หรือศูนย์
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 จึงจะทำงานก็ต่อเมื่อคำถามทั้งสองข้อข้างต้นตอบว่า 'ไม่' เท่านั้น
n is -4. Print positive, negative or zero — whichever n is. · n คือ -4. พิมพ์ positive, negative หรือ zero — ขึ้นอยู่กับว่า n เป็นอะไร
Click Run to see the output here. · คลิก Run เพื่อดูผลลัพธ์ที่นี่