Chapter 01: Introduction to Python — Exercises¶
Overview¶
These exercises help you understand what Python is, why it matters, and what you can expect to build with it. They are not coding exercises — they are reflection and exploration tasks that prepare you for the practical work ahead.
How to Use These Exercises¶
- Work through each section in order.
- For reflection questions, write your answers in a text file or notebook.
- For exploration tasks, use the Python REPL or write small scripts.
- There are no "wrong" answers to reflection questions — the goal is to think about the concepts.
Warm-up: Reflection Questions¶
Answer these questions in your own words. They help you solidify what you learned.
-
What is Python? Explain it to someone who has never programmed before.
-
Why is Python called an interpreted language? What does that mean for how you write and run code?
-
Name three real-world uses of Python that you learned about in the handbook.
-
What does "readability counts" mean? Why would a programming language prioritize readability?
-
What is the difference between Python 2 and Python 3? Why should you only use Python 3?
Practice Exercises¶
Exercise 1: Explore the Zen of Python¶
Open a Python REPL and run:
Read the output carefully. Then answer:
- Which principle resonates most with you? Why?
- Pick one principle and explain what it means in your own words.
- Find a principle that seems to contradict another. How do you think they work together?
Expected behavior: The Zen of Python prints a poem with 19 principles.
Exercise 2: Understand Python's Versatility¶
Research and document one real-world project or company that uses Python. Find:
- What the project or company does
- How they use Python (what part of their system)
- Why Python was a good choice for that use case
Write a short paragraph (3–5 sentences) summarizing your findings.
Hint: Look at the handbook's section on "Where Python Is Used Today" for starting points.
Exercise 3: Identify Python's Limitations¶
The handbook lists several domains where Python is not the right tool. For each one, research and explain:
- Why Python is not suitable for that domain
- What language or tool is typically used instead
- One example of a project in that domain
Write 2–3 sentences for each domain.
Domains to research: - Mobile app development - Game development - Ultra-low-latency systems
Exercise 4: Reflect on Your Learning Goals¶
Before you dive into the practical chapters, think about why you are learning Python.
- What do you want to build or accomplish with Python? Be specific.
- What excites you most about learning to program?
- What concerns or worries you?
- How will you know when you have learned enough Python to do what you want?
Write a short paragraph for each question. Save this somewhere — you will revisit it after finishing the handbook.
Challenge Exercises¶
Challenge 1: Compare Python to Another Language¶
If you have experience with another programming language (JavaScript, Java, C, etc.), compare it to Python:
- What is easier in Python?
- What is harder in Python?
- When would you choose Python over the other language?
- When would you choose the other language over Python?
Write 2–3 sentences for each question.
Challenge 2: Explore Python's History¶
Research one of these topics and write a short summary (3–5 paragraphs):
- Guido van Rossum and Python's origins — What was he trying to improve about existing languages?
- The Python 2 to Python 3 transition — Why was it so difficult, and what did it teach the Python community?
- Python's rise in data science — How did Python become the dominant language for data science and machine learning?
Challenge 3: Evaluate Python for a Hypothetical Project¶
Imagine you are building one of these projects. For each, decide whether Python is a good choice and explain why or why not.
- A mobile app for iOS and Android
- A web server that handles 1 million requests per second
- A data analysis tool that processes CSV files and generates reports
- A real-time multiplayer game
- A command-line tool for system administrators
- A machine learning model that classifies images
For each, write 2–3 sentences explaining your decision.
Hints¶
For reflection questions: There are no "wrong" answers. The goal is to think deeply about the concepts. If you are unsure, re-read the relevant section of the handbook.
For exploration tasks: Use the Python REPL to experiment. Type help(topic) to learn more about anything that interests you.
For research tasks: Start with the handbook's sections on "Where Python Is Used Today" and "What Python Is NOT Good For." Then search online for specific examples.
What to Review If You Get Stuck¶
- What is Python? → Handbook section 3.1
- Why Python became popular → Handbook section 3.3
- Where Python is used → Handbook section 3.4
- Python's design philosophy → Handbook section 3.5
- What Python is not good for → Handbook section 3.6
- The Zen of Python → Handbook section 3.7
Key Takeaways¶
After completing these exercises, you should be able to:
- Explain what Python is and why it matters
- Describe at least three real-world uses of Python
- Understand Python's design philosophy and how it shapes the language
- Recognize situations where Python is and is not the right tool
- Feel confident and excited about learning Python