Python Programming — Practice Question Bank
150+ Problems with Fully Worked Solutions
Independent Study Resource
Not affiliated with or endorsed by Yale University
Based on OpenStax Introduction to Python Programming (CC BY 4.0)
Edition 2026
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
,Table of Contents
1. How to Use This Question Bank
2. Chapter 1: Computational Thinking and Python Basics — 10 problems
3. Chapter 2: Variables, Types, and Operators — 12 problems
4. Chapter 3: Strings, Input, and Output — 12 problems
5. Chapter 4: Conditionals and Boolean Reasoning — 12 problems
6. Chapter 5: Loops and Iteration — 12 problems
7. Chapter 6: Collections — 12 problems
8. Chapter 7: Functions, Scope, and Decomposition — 12 problems
9. Chapter 8: File Handling and Structured Data — 10 problems
10. Chapter 9: Algorithms and Efficiency — 10 problems
11. Chapter 10: Data Analysis with pandas — 10 problems
12. Chapter 11: Visualization with matplotlib — 10 problems
13. Chapter 12: Statistics and Regression — 10 problems
14. Chapter 13: Web Data, APIs, and Ethics — 8 problems
15. Chapter 14: Debugging, Testing, and Projects — 8 problems
16. Final Mixed Practice Exam — 20 problems
17. Full Answer Key with Worked Solutions
18. Quick Python Reference
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
,How to Use This Question Bank
This question bank complements the CPSC 1100 Complete Study Guide. Where the guide teaches the
concepts, this bank trains you to apply them under exam conditions.
Recommended workflow
1. Attempt each problem without looking at the solution. Set a timer: 3–5 minutes for code
tracing, 5–10 minutes for writing functions.
2. Check your reasoning. Compare against the worked solution.
3. Re-do missed problems after 48 hours. Spaced repetition is the strongest retention tool.
4. Use the final mixed exam last. It integrates everything under one time limit.
Difficulty Legend
[C] Computational — trace code or apply a rule.
[A] Applied — write a short program or function.
[X] Analysis — explain behavior or find bugs.
[★] Challenge — exam-level, multi-step.
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF
, Chapter 1 — Computational Thinking and Python
Basics
Problems
1.1 [C] Define computational thinking and list its four pillars.
1.2 [A] Write a Python program that prints your name.
1.3 [X] What is the difference between a compiler and an interpreter?
1.4 [C] What does print("Hello, world!") do?
1.5 [X] Why is Python called a high-level language?
1.6 [A] Write a program that prints three lines of text.
1.7 [C] What is the extension of a Python source file?
1.8 [X] Explain why Python uses indentation instead of braces.
1.9 [★] Explain what happens, step by step, when you run a Python script.
1.10 [★] Describe one problem in data science where computational thinking helps.
Worked Solutions
1.1 Decomposition, pattern recognition, abstraction, algorithm design.
1.2 print("Your Name")
1.3 Compiler translates all code before execution; interpreter executes line by line.
1.4 Displays the text "Hello, world!" to the console.
1.5 It uses human-readable syntax and abstracts away hardware details.
1.6 print("Line 1"); print("Line 2"); print("Line 3")
1.7 .py
1.8 Indentation improves readability and enforces structure.
1.9 (1) Python interpreter reads the file. (2) Parses syntax. (3) Executes top to bottom. (4) Prints output.
Explore our developer-friendly HTML to PDF API Printed using PDFCrowd HTML to PDF