ควิซ Python Tricky Python Questions

This hard Python quiz is full of snippets that look simple but behave in surprising ways. It covers equal dict keys, operator precedence, nan, empty iterables, class scope and other traps interviewers love to ask about.

ยาก 10 ข้อ ~8 นาที ผ่านที่ 80% Python 3.12

เลือกโหมด

กำลังเล่นแบบผู้เยี่ยมชม: เข้าสู่ระบบเพื่อเก็บ XP และ streak

ตัวอย่างคำถาม

ข้อ 1 จาก 10

What does this print?

d = {True: "a", 1: "b", 1.0: "c"}
print(d)
ดูเฉลย

C. {True: 'c'} True == 1 == 1.0 and they have the same hash, so all three are the same key. The first key object (True) is kept, while each later assignment replaces the value, ending with 'c'.

ควิซนี้มีเนื้อหาอะไรบ้าง

  • Dict keys that are equal, like True, 1 and 1.0
  • Operator precedence with ** and unary minus
  • When a generator expression reads its names
  • nan, all([]) and other edge cases
  • Changing a dict while looping over it, and class body scope

คำถามที่พบบ่อย

ต้องมีบัญชีไหม?

ไม่ต้อง ใครก็เล่นได้ เข้าสู่ระบบเพื่อเก็บ XP, streak, เหรียญตรา และประวัติ

ใช้ Python เวอร์ชันไหน?

Python 3.12 ทุกคำถามเกี่ยวกับผลลัพธ์ผ่านการรันโค้ดจริงเพื่อตรวจสอบแล้ว

ทำซ้ำได้ไหม?

ได้ ระบบเก็บคะแนนที่ดีที่สุดไว้ และสลับคำถามกับตัวเลือกใหม่ทุกครั้ง