ควิซ Python Output-Based Python Questions

Many Python interviews hand you a snippet and ask "what does this print?". This quiz is ten of those, each mixing two ideas such as rebinding vs mutation, slicing with steps, sort keys or exhausted generators.

ปานกลาง 10 ข้อ ~6 นาที ผ่านที่ 80% Python 3.12

เลือกโหมด

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

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

ข้อ 1 จาก 10

What does this print?

a = [1]
b = a
a = a + [2]
c = [1]
d = c
c += [2]
print(b, d)
ดูเฉลย

A. [1] [1, 2] a + [2] builds a new list and rebinds a, so b still points to the old [1]. c += [2] extends the list in place, and d is that same list, so it shows [1, 2].

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

  • a = a + [x] vs a += [x]
  • Slicing with steps and negative steps
  • Dict comprehensions with repeated keys
  • Sort keys that use tuples
  • Generators that can only be used once

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

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

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

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

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

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

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