Python Programming
Foundations
ORIGINAL MULTIPLE-CHOICE QUESTIONS WITH VERIFIED
ANSWERS & RATIONALES
ALL CHAPTERS | UPDATED EDITION
Topics typical of WGU C859-style Introduction to Programming in Python
courses — not affiliated with or endorsed by WGU or any institution
500 multiple-choice questions · 10 chapters · Verified answer and rationale
after every question · Full answer key at the end
Original practice questions written for study and self-assessment. Not affiliated with, endorsed by, or taken
from any school, instructor, course, publisher, testing company or official exam.
Python Programming Foundations Page 1
, How to Use This Paper
This paper contains 500 original multiple-choice questions organized into ten chapters covering
Python basics · Strings · Lists & tuples · Dictionaries & sets · Control flow · Functions & scope ·
Modules, files & exceptions · OOP · Algorithms & good practice · Programming concepts & the
development process.
Each question has one best answer. Work through a chapter without looking at the key, then
check your answers in the Answer Key and Rationales section at the end. Every answer comes
with a short rationale explaining why it is correct, so you can review the concept behind any
question you miss.
Suggested approach: aim for 80% or better on each chapter before moving on, and revisit the
rationales for every missed question. Mixing chapters in a timed session of 50 questions in 60
minutes is good preparation for cumulative exams.
Contents
Ch. Topic Questions
1 Python Basics: Variables, Data Types and Expressions 1–50
2 Strings and String Methods 51–100
3 Lists and Tuples 101–150
4 Dictionaries and Sets 151–200
5 Control Flow: Conditionals and Loops 201–250
6 Functions, Parameters and Scope 251–300
7 Modules, Files and Exception Handling 301–350
8 Object-Oriented Programming 351–400
9 Algorithms, Problem Solving and Good Practice 401–450
Programming Concepts, Data Structures and the Development
10 451–500
Process
Answer Key and Rationales —
Python Programming Foundations Page 2
, Chapter 1: Python Basics: Variables, Data Types
and Expressions
1. Which of the following is a valid Python variable name?
A. total_marks
B. 2nd_total
C. total-marks
D. class
Verified Answer: A. total_marks
Rationale: Names may contain letters, digits and underscores but cannot start with a digit, contain
hyphens or be a reserved keyword such as class.
2. Python is described as dynamically typed because:
A. Variables can never change value
B. It only supports numbers
C. Types must be declared before use
D. A variable's type is determined by the value assigned at run time and can change
Verified Answer: D. A variable's type is determined by the value assigned at run time
and can change
Rationale: In Python, names are bound to objects; the same name can later refer to an object of a
different type.
3. Which value is of type float?
A. 7.0
B. 7
C. '7.0'
D. True
Verified Answer: A. 7.0
Rationale: A number with a decimal point is a float; quotes would make it a string.
4. The result of int(9.99) is:
A. 10
B. 9
C. 9.99
D. An error
Verified Answer: B. 9
Rationale: int() truncates toward zero; it does not round, so 9.99 becomes 9.
5. Which function reads text typed by the user at the keyboard?
A. print()
B. scan()
C. input()
D. read()
Verified Answer: C. input()
Rationale: input() always returns a string, so numeric input must be converted with int() or float().
Python Programming Foundations Page 3
, 6. Ruth writes age = input('Age? ') and then age + 1. What happens?
A. Python converts age automatically
B. age increases by 1
C. A TypeError, because input() returns a string
D. age becomes '11'
Verified Answer: C. A TypeError, because input() returns a string
Rationale: Strings and integers cannot be added; she should use int(input('Age? ')).
7. Python uses indentation to:
A. Declare variable types
B. Make code look nicer only
C. Mark comments
D. Define code blocks such as the body of a loop or function
Verified Answer: D. Define code blocks such as the body of a loop or function
Rationale: Unlike many languages that use braces, Python's block structure is defined by
consistent indentation.
8. Which operator checks whether two values are equal?
A. =
B. !=
C. ===
D. ==
Verified Answer: D. ==
Rationale: = assigns a value; == compares values. Python has no === operator.
9. The expression not True or False evaluates to:
A. True
B. False
C. None
D. An error
Verified Answer: B. False
Rationale: not binds tighter than or: not True is False, and False or False is False.
10. Which of these values is considered "falsy" in a condition?
A. [0]
B. 0
C. '0'
D. 1
Verified Answer: B. 0
Rationale: Zero, empty strings, empty containers and None are falsy; '0' and [0] are non-empty, so
they are truthy.
11. The is operator tests whether two names:
A. Are both strings
B. Refer to the same object in memory
C. Are both numbers
D. Have equal values
Verified Answer: B. Refer to the same object in memory
Rationale: Use == for value equality and is for identity, typically with None (x is None).
Python Programming Foundations Page 4
Foundations
ORIGINAL MULTIPLE-CHOICE QUESTIONS WITH VERIFIED
ANSWERS & RATIONALES
ALL CHAPTERS | UPDATED EDITION
Topics typical of WGU C859-style Introduction to Programming in Python
courses — not affiliated with or endorsed by WGU or any institution
500 multiple-choice questions · 10 chapters · Verified answer and rationale
after every question · Full answer key at the end
Original practice questions written for study and self-assessment. Not affiliated with, endorsed by, or taken
from any school, instructor, course, publisher, testing company or official exam.
Python Programming Foundations Page 1
, How to Use This Paper
This paper contains 500 original multiple-choice questions organized into ten chapters covering
Python basics · Strings · Lists & tuples · Dictionaries & sets · Control flow · Functions & scope ·
Modules, files & exceptions · OOP · Algorithms & good practice · Programming concepts & the
development process.
Each question has one best answer. Work through a chapter without looking at the key, then
check your answers in the Answer Key and Rationales section at the end. Every answer comes
with a short rationale explaining why it is correct, so you can review the concept behind any
question you miss.
Suggested approach: aim for 80% or better on each chapter before moving on, and revisit the
rationales for every missed question. Mixing chapters in a timed session of 50 questions in 60
minutes is good preparation for cumulative exams.
Contents
Ch. Topic Questions
1 Python Basics: Variables, Data Types and Expressions 1–50
2 Strings and String Methods 51–100
3 Lists and Tuples 101–150
4 Dictionaries and Sets 151–200
5 Control Flow: Conditionals and Loops 201–250
6 Functions, Parameters and Scope 251–300
7 Modules, Files and Exception Handling 301–350
8 Object-Oriented Programming 351–400
9 Algorithms, Problem Solving and Good Practice 401–450
Programming Concepts, Data Structures and the Development
10 451–500
Process
Answer Key and Rationales —
Python Programming Foundations Page 2
, Chapter 1: Python Basics: Variables, Data Types
and Expressions
1. Which of the following is a valid Python variable name?
A. total_marks
B. 2nd_total
C. total-marks
D. class
Verified Answer: A. total_marks
Rationale: Names may contain letters, digits and underscores but cannot start with a digit, contain
hyphens or be a reserved keyword such as class.
2. Python is described as dynamically typed because:
A. Variables can never change value
B. It only supports numbers
C. Types must be declared before use
D. A variable's type is determined by the value assigned at run time and can change
Verified Answer: D. A variable's type is determined by the value assigned at run time
and can change
Rationale: In Python, names are bound to objects; the same name can later refer to an object of a
different type.
3. Which value is of type float?
A. 7.0
B. 7
C. '7.0'
D. True
Verified Answer: A. 7.0
Rationale: A number with a decimal point is a float; quotes would make it a string.
4. The result of int(9.99) is:
A. 10
B. 9
C. 9.99
D. An error
Verified Answer: B. 9
Rationale: int() truncates toward zero; it does not round, so 9.99 becomes 9.
5. Which function reads text typed by the user at the keyboard?
A. print()
B. scan()
C. input()
D. read()
Verified Answer: C. input()
Rationale: input() always returns a string, so numeric input must be converted with int() or float().
Python Programming Foundations Page 3
, 6. Ruth writes age = input('Age? ') and then age + 1. What happens?
A. Python converts age automatically
B. age increases by 1
C. A TypeError, because input() returns a string
D. age becomes '11'
Verified Answer: C. A TypeError, because input() returns a string
Rationale: Strings and integers cannot be added; she should use int(input('Age? ')).
7. Python uses indentation to:
A. Declare variable types
B. Make code look nicer only
C. Mark comments
D. Define code blocks such as the body of a loop or function
Verified Answer: D. Define code blocks such as the body of a loop or function
Rationale: Unlike many languages that use braces, Python's block structure is defined by
consistent indentation.
8. Which operator checks whether two values are equal?
A. =
B. !=
C. ===
D. ==
Verified Answer: D. ==
Rationale: = assigns a value; == compares values. Python has no === operator.
9. The expression not True or False evaluates to:
A. True
B. False
C. None
D. An error
Verified Answer: B. False
Rationale: not binds tighter than or: not True is False, and False or False is False.
10. Which of these values is considered "falsy" in a condition?
A. [0]
B. 0
C. '0'
D. 1
Verified Answer: B. 0
Rationale: Zero, empty strings, empty containers and None are falsy; '0' and [0] are non-empty, so
they are truthy.
11. The is operator tests whether two names:
A. Are both strings
B. Refer to the same object in memory
C. Are both numbers
D. Have equal values
Verified Answer: B. Refer to the same object in memory
Rationale: Use == for value equality and is for identity, typically with None (x is None).
Python Programming Foundations Page 4