Python Programming MCQs

20 practice MCQs on this page Page 2 of 3

Tap an option to check your answer — the correct answer and full explanation appear after you choose.

ProgrammingPython Programming PPSC FPSC NTSID: PROG-100

What is the output of this Python code? print(9 // 2)

  1. A5.
  2. B4.5.
  3. C4. ✓ Correct answer
  4. D3.
ProgrammingPython Programming PPSC FPSC NTSID: PROG-105

In Python, which function tells you the type of a value?

  1. Alen()
  2. Btype() ✓ Correct answer
  3. Cprint()
  4. Dstr()
ProgrammingPython Programming PPSC FPSC NTSID: PROG-110

In Python, which keyword begins a loop that keeps running while a condition is true?

  1. Adef
  2. Bwhile ✓ Correct answer
  3. Cif
  4. Dreturn
ProgrammingPython Programming PPSC FPSC NTSID: PROG-115

What is the output of this Python code? print(15 % 4)

  1. A3 ✓ Correct answer
  2. B4
  3. C1
  4. D0
ProgrammingPython Programming PPSC FPSC NTSID: PROG-120

What is the output of this Python code? print(10 - 4 * 2)

  1. A12
  2. B10
  3. C4
  4. D2 ✓ Correct answer
ProgrammingPython Programming BPSCID: BPP-2785

In Python, a comment begins with the symbol:

  1. A/*
  2. B//
  3. C# ✓ Correct answer
  4. D--
ProgrammingPython Programming FPSCID: FPP-11397

In programming, a variable is used to:

  1. APrint output
  2. BDraw graphics
  3. CStore data ✓ Correct answer
  4. DConnect to the internet
ProgrammingPython Programming FPSCID: FPP-11398

In Python, which data type is used for whole numbers?

  1. Astr
  2. Bfloat
  3. Cint ✓ Correct answer
  4. Dbool
ProgrammingPython Programming FPSCID: FPP-11399

In Python, which data type is used for text?

  1. Aint
  2. Bfloat
  3. Cstr ✓ Correct answer
  4. Dlist
ProgrammingPython Programming FPSCID: FPP-11400

In Python, the output of print(2 + 3) is:

  1. A2
  2. B23
  3. C5 ✓ Correct answer
  4. D6
ProgrammingPython Programming PPSCID: LTP-7690

In Python, which keyword starts a loop that repeats while a condition remains true?

  1. Afor
  2. Bif
  3. Cwhile ✓ Correct answer
  4. Ddef
ProgrammingPython Programming PPSCID: LTP-7691

In Python, which function is used to display output on the screen?

  1. Ascan()
  2. Bshow()
  3. Cdisplay()
  4. Dprint() ✓ Correct answer
ProgrammingPython Programming PPSCID: LTP-7692

Which Python data type is mutable, meaning its contents can be changed after creation?

  1. AList ✓ Correct answer
  2. BTuple
  3. CString
  4. DInteger
ProgrammingPython Programming PPSCID: LTP-7693

Which Python data type is immutable, meaning it cannot be changed after creation?

  1. AList
  2. BTuple ✓ Correct answer
  3. CDictionary
  4. DSet
ProgrammingPython Programming PPSCID: LTP-7694

In Python, what does the expression 2 ** 3 evaluate to?

  1. A6
  2. B9
  3. C8 ✓ Correct answer
  4. D5
ProgrammingPython Programming PPSCID: LTP-7695

In Python, blocks of code such as the body of a loop are defined by:

  1. ACurly braces
  2. BSemicolons
  3. CRound brackets
  4. DIndentation ✓ Correct answer
ProgrammingPython Programming PPSCID: LTP-7696

In Python, which function returns the number of items in a list?

  1. Alen() ✓ Correct answer
  2. Bcount()
  3. Csize()
  4. Dlength()
ProgrammingPython Programming PPSCID: LTP-7697

A Python dictionary stores data as:

  1. AOnly numbers
  2. BKey-value pairs ✓ Correct answer
  3. COnly images
  4. DSorted pages
ProgrammingPython Programming PPSCID: LTP-7698

In Python, which symbol starts a single-line comment?

  1. A//
  2. B/*
  3. C# ✓ Correct answer
  4. D--
ProgrammingPython Programming PPSCID: LTP-7699

Python is best described as which type of language?

  1. AMachine code only
  2. BAssembly only
  3. CA markup language
  4. DInterpreted ✓ Correct answer

Practice these MCQs interactively