KAHIBARO Bookshelves
Discord Login Register

18.1. How to practice Python

Why Practice Matters

Python skills grow the same way muscles do: through regular, focused practice.

You don’t need hours every day. Even 20–30 minutes of smart practice, most days of the week, will move you forward much faster than occasional long sessions.

This chapter is about how to practice so you actually improve:

  • What to practice at different stages
  • How to design your own exercises
  • How to use small projects effectively
  • How to get feedback and avoid “fake progress”
  • How to build a sustainable practice routine

You can adapt everything here to your own schedule and interests.


Principles of Effective Practice

1. Practice a little, often

Consistency beats intensity. Aim for:

  • 20–30 minutes per day, 4–6 days per week
  • Or 1–2 longer sessions per week if that’s all you can do

Ideas for “small” daily practice:

  • Solve 1–3 short coding exercises
  • Extend an existing tiny project by one feature
  • Rewrite an old solution in a cleaner way
  • Read and run someone else’s simple code, then change it

2. Focus on one main skill at a time

Trying to learn everything at once is overwhelming. For a given week (or session), pick a main focus, such as:

  • Using if/else and loops confidently
  • Practicing functions and return values
  • Getting comfortable with lists and dictionaries
  • Reading and understanding error messages

You’ll still use other skills, but you measure progress on the one you chose.

3. Practice slightly above your comfort zone

Good practice is:

  • Not so easy that you’re bored
  • Not so hard that you’re stuck for an hour with no idea what to do

A good target: problems where you need to think, maybe search once or twice, but can still make progress.

If you’re totally stuck:

  1. Break the problem into a smaller version
  2. Solve that tiny version first
  3. Add one more piece at a time

4. Write code, don’t just watch

Watching tutorials feels productive, but you only really learn when you:

  • Type the code yourself (not copy–paste)
  • Change it and see what happens
  • Predict what code will do before you run it

When you see an example, try:

  1. Type it yourself
  2. Run it
  3. Make at least 2–3 modifications:
    • Change values
    • Add a new print
    • Break it on purpose and read the error

5. Embrace mistakes as part of practice

Errors are not a sign of failure; they are the practice.

When something doesn’t work:

  • Read the error message carefully
  • Fix only one thing at a time
  • Re-run and see what changed

Keep a small “error diary”:

  • Note down errors you keep repeating
  • Write how you fixed them
  • Glance at it every few days

You’ll be surprised how much faster you learn this way.


What to Practice at Different Stages

Early beginner: Just finished basics

If you’ve just gone through the fundamentals (variables, conditions, loops, functions, basic collections), focus on:

Goals:

  • Remember syntax without constantly looking everything up
  • Understand how code flows line by line
  • Get comfortable reading and modifying simple programs

Practice ideas:

  • Recreate small textbook examples from memory
  • Do simple “pattern” exercises:
    • Ask for input, check a condition, print something
    • Use a for loop to repeat something 5–10 times
    • Use a while loop that stops when the user types quit
  • Implement tiny tools:
    • Tip calculator
    • Temperature converter (Celsius/Fahrenheit)
    • Simple “greeting” program that uses name and age

Don’t worry yet about “advanced” things. Just get lots of reps with the basics.

Growing beginner: Comfortable with basics

Once you know the basic syntax and can solve small tasks, practice should:

  • Combine multiple concepts
  • Use lists, dictionaries, and functions together
  • Work with slightly bigger scripts (20–100 lines)

Practice ideas:

  • Turn repeated code into functions
  • Store data in lists/dicts instead of separate variables
  • Add simple validation (e.g., “age must be a number > 0”)
  • Work through easy problems on coding practice sites
  • Start a small persistent mini-project you come back to

Intermediate beginner: Ready for small projects

Now you can:

  • Plan and build small programs from scratch
  • Read other people’s simple code
  • Debug most of your own errors

Practice ideas:

  • Build small projects end-to-end
  • Rewrite or refactor older code to be cleaner
  • Use basic file handling or simple libraries (depending on what you’ve learned)
  • Start exploring your preferred specialization (web, data, automation, etc.)

The rest of this chapter gives you concrete structures and routines for all of these stages.


Types of Practice You Should Mix

1. Drills: Short, focused exercises

Drills are small, repetitive tasks that target one skill.

Examples:

  • “Write 5 if/elif/else examples with different conditions.”
  • “Create 3 functions that take inputs and return a result.”
  • “Write 5 loops that operate on lists (sum, count, find max, filter items).”

How to do drills well:

  • Time-box them (e.g., 15–20 minutes)
  • Don’t worry about perfect design; just get reps
  • Check your answers by printing and testing

2. Problem-solving practice

Here you solve standalone tasks that require thinking, not just repeating.

Examples:

  • “Given a list of numbers, print only the even ones.”
  • “Ask for 5 names, store them, then print them in reverse order.”
  • “Simulate a simple dice game with random numbers.”

Tips:

  • Before coding, write a short plain-language plan
  • After solving, ask: “Is there a simpler way to do this?”
  • Save your solutions so you can compare your style later

3. Mini-projects

Mini-projects are “small but complete” programs:

  • They have a clear purpose
  • They combine multiple topics
  • You can show/demonstrate them to someone

Examples for practice:

  • Number guessing game
  • Text-based to-do list
  • Simple quiz with score
  • Password generator with options (length, symbols, etc.)

Use mini-projects to practice:

  • Planning before coding
  • Organizing code (functions, separate files as you progress)
  • Handling invalid input gracefully

4. Reading and modifying code

Practice is not only writing new code; it’s also reading and changing existing code.

Ideas:

  • Revisit your older programs and add:
    • Comments
    • Better variable names
    • Functions instead of repeated code
  • Take sample code from tutorials and:
    • Predict what it will do
    • Run it to check your understanding
    • Change small parts and observe effects

This builds the skill you’ll use constantly in real programming: understanding code someone else wrote (including your past self).


Designing Your Own Exercises

You don’t always need external exercises. You can create your own from everyday life.

Start from a tiny real-world task

Think of something you do that involves:

  • Repeating similar steps
  • Simple calculations
  • Text processing

Examples:

  • Splitting a full name into first and last name
  • Calculating total cost with tax and tip
  • Converting times (minutes to hours/minutes)

Turn it into an exercise:

  • Input: What information will the user give?
  • Processing: What will your program calculate or decide?
  • Output: What will it show?

Use “what if” questions

Take an existing tiny program and ask:

  • What if I needed to:
    • Support more than one user?
    • Handle invalid input?
    • Save results to a file?
    • Let the user repeat the action until they quit?

Each “what if” becomes a practice exercise.

Level up an exercise in stages

Example: You have a simple program that asks for two numbers and prints the sum.

Levels:

  1. Add subtraction, multiplication, and division.
  2. Put each operation into its own function.
  3. Let the user choose the operation.
  4. Add input validation (no division by zero, must be numbers).
  5. Put it in a loop so the user can perform multiple calculations.

Each level is still manageable, but together they build real skill.


Building a Practice Routine

Example weekly plan (busy schedule)

Assume you have about 30 minutes per day, 5 days a week.

Day 1 – Drills (syntax and basics)

  • 10 min: small drills (variables, if, loops, functions)
  • 20 min: one short exercise using those basics

Day 2 – Problem-solving

  • 30 min: one or two small problems (e.g., from a practice site or your own ideas)

Day 3 – Mini-project work

  • 10 min: plan next steps for your mini-project (write a to-do list)
  • 20 min: implement one small feature

Day 4 – Review and refactor

  • 15 min: read and clean up yesterday’s code (rename variables, add comments)
  • 15 min: add one improvement or fix a bug

Day 5 – Mixed practice

  • 15 min: new exercise using something you find hard
  • 15 min: brainstorm or sketch ideas for your next mini-project

Adjust this to your life, but keep the pattern:

  • Some drills
  • Some problem-solving
  • Some project work
  • Some review/cleanup

Tracking your progress

Simple ways to see improvement:

  • Keep a practice log:
    • Date
    • What you worked on
    • What you found hard
    • One thing you learned
  • Save all your code in dated folders or a version control system (like Git) once you’re ready
  • Every few weeks, revisit an old problem and solve it again more cleanly

Seeing your old code look “messy” to you is a sign you’re getting better.


Using Online Resources Effectively

Many websites offer Python practice. Use them wisely:

Exercise and challenge sites

Look for:

  • Beginner-friendly exercises
  • Clear problem descriptions
  • Ability to run code in the browser (if you don’t want to set up anything)

How to use them:

  • Start with the “easy” or “beginner” section
  • Don’t rush into very hard problems; aim for steady success
  • After solving:
    • Read one or two other people’s solutions
    • Compare and see one improvement you could adopt

Tutorials and videos

When following a tutorial:

  • Don’t just watch; type every line yourself
  • Pause and predict what will happen before running code
  • After finishing, close the tutorial and:
    • Rebuild a smaller version from memory
    • Change it to do something slightly different

Documentation and search

During practice, you should look things up:

  • Exact function names
  • Method usage (e.g., list methods)
  • Small details of syntax

This is normal. Over time, the most common things will stick.


Getting Feedback and Help

Programming is much easier when you’re not stuck alone.

Asking good questions

When you need help, include:

  • A short description of what you’re trying to do
  • The exact code you’re using (small, complete example)
  • The full error message (copied, not summarized)
  • What you already tried

This makes it easier for others (and your future self) to help.

Pairing and code review

If possible:

  • Study with a friend
  • Show each other your code
  • Explain your approach out loud

Explaining your code is powerful practice—it reveals gaps in your understanding.


Avoiding Common Practice Traps

Trap 1: Only watching, never typing

If you spend hours watching tutorials but struggle when the screen is blank, you’re not really practicing.

Fix: For every hour of watching, aim for at least an hour of doing.

Trap 2: Doing the same easy thing forever

If all your practice feels “comfortable”, you’re not really growing.

Fix: Regularly choose exercises that feel a bit challenging. It’s okay to be unsure at first.

Trap 3: Jumping to big frameworks too soon

It’s tempting to rush into complex tools (web frameworks, big data libraries) before you’re ready.

Fix: Make sure your core Python is solid:

  • You can read and write basic scripts without constant copying
  • You understand and use functions, loops, and basic data structures

This makes learning advanced tools much easier later.

Trap 4: Giving up when code doesn’t work immediately

Even experienced developers spend a lot of time debugging.

Fix:

  • Use print statements to see what’s happening
  • Change one thing at a time
  • Treat debugging as a puzzle, not a failure

Turning Practice Into a Habit

To make Python practice stick:

  • Attach it to something you already do:
    • After breakfast
    • During lunch break
    • Before bed
  • Lower the barrier:
    • “I’ll do just 10 minutes” is easier to start than “I must code for an hour”
  • Celebrate small wins:
    • Solved one exercise?
    • Fixed a bug that annoyed you?

Note it down. You’re building momentum.


Putting It All Together

To practice Python effectively:

  1. Practice regularly, in small chunks.
  2. Mix drills, problem-solving, and mini-projects.
  3. Gradually increase difficulty, but not too fast.
  4. Revisit and improve old code.
  5. Use online resources actively, not passively.
  6. Ask for help when you’re stuck, with clear questions.

If you keep writing code—even a little—most days, your skills will grow faster than you expect.

Views: 0

Comments

Please login to add a comment.

Don't have an account? Register now!

Where to Move

Move chapter:

  • ☰ 1. Chapter 1: What Is Programming?
    • ☰ 1.1. What is a computer program?
      • ☰ 1.2. What is Python?
        • ☰ 1.3. Where is Python used?
          • ☰ 1.4. How programming helps solve problems
            • ☰ 1.5. Your first Python program
            • ☰ 2. Chapter 2: Setting Up Python
              • ☰ 2.1. Installing Python (Windows / macOS / Linux)
                • ☰ 2.2. Using Python in the terminal
                  • ☰ 2.3. Using an IDE (IDLE / VS Code)
                    • ☰ 2.4. Running Python scripts
                      • ☰ 2.5. Python interactive mode
                      • ☰ 3. Chapter 3: Variables and Data Types
                        • ☰ 3.1. What is a variable?
                          • ☰ 3.2. Creating variables
                            • ☰ 3.3. Numbers
                              • ☰ 3.4. Test
                                • ☰ 3.5. Boolean values
                                  • ☰ 3.6. Type checking
                                  • ☰ 4. Chapter 4: Basic Operations
                                    • ☰ 4.1. Arithmetic operations
                                      • ☰ 4.2. Working with numbers
                                        • ☰ 4.3. String operations
                                          • ☰ 4.4. Combining text and variables
                                            • ☰ 4.5. Comments in Python
                                            • ☰ 5. Chapter 5: User Input and Output
                                              • ☰ 5.1. Getting input from the user
                                                • ☰ 5.2. Converting input to numbers
                                                  • ☰ 5.3. Formatting output
                                                    • ☰ 5.4. Writing interactive programs
                                                    • ☰ 6. Chapter 6: Conditions
                                                      • ☰ 6.1. Comparison operators
                                                        • ☰ 6.2. Logical operators
                                                          • ☰ 6.3. if, elif, else
                                                            • ☰ 6.4. Nested conditions
                                                              • ☰ 6.5. Common beginner mistakes
                                                              • ☰ 7. Chapter 7: Loops
                                                                • ☰ 7.1. Why loops are useful
                                                                  • ☰ 7.2. for loops
                                                                    • ☰ 7.3. while loops
                                                                      • ☰ 7.4. Loop counters
                                                                        • ☰ 7.5. break and continue
                                                                          • ☰ 7.6. Loop exercises
                                                                          • ☰ 8. Chapter 8: Data Collections
                                                                            • ☰ 8.1. Lists
                                                                              • ☰ 8.2. Tuples
                                                                                • ☰ 8.3. Dictionaries
                                                                                  • ☰ 8.4. Sets (basics)
                                                                                    • ☰ 8.5. Choosing the right data structure
                                                                                    • ☰ 9. Chapter 9: Functions
                                                                                      • ☰ 9.1. Why functions matter
                                                                                        • ☰ 9.2. Defining functions
                                                                                          • ☰ 9.3. Parameters and arguments
                                                                                            • ☰ 9.4. Return values
                                                                                              • ☰ 9.5. Scope (local vs global)
                                                                                                • ☰ 9.6. Reusing code
                                                                                                • ☰ 10. Chapter 10: Working with Files
                                                                                                  • ☰ 10.1. What is a file?
                                                                                                    • ☰ 10.2. Reading text files
                                                                                                      • ☰ 10.3. Writing and appending files
                                                                                                        • ☰ 10.4. File paths
                                                                                                          • ☰ 10.5. Simple file-based programs
                                                                                                          • ☰ 11. Chapter 11: Errors and Debugging
                                                                                                            • ☰ 11.1. Types of errors
                                                                                                              • ☰ 11.2. Reading error messages
                                                                                                                • ☰ 11.3. Common beginner errors
                                                                                                                  • ☰ 11.4. try and except
                                                                                                                    • ☰ 11.5. Debugging strategies
                                                                                                                    • ☰ 12. Chapter 12: Using Python Libraries
                                                                                                                      • ☰ 12.1. What is a library?
                                                                                                                        • ☰ 12.2. Importing modules
                                                                                                                          • ☰ 12.3. Standard libraries
                                                                                                                            • ☰ 12.3.1. math
                                                                                                                              • ☰ 12.3.2. random
                                                                                                                                • ☰ 12.3.3. datetime
                                                                                                                                • ☰ 12.4. Installing external libraries with pip
                                                                                                                                • ☰ 13. Chapter 13: Object-Oriented Programming
                                                                                                                                  • ☰ 13.1. What is object-oriented programming?
                                                                                                                                    • ☰ 13.2. Classes and objects
                                                                                                                                      • ☰ 13.3. The `__init__` method
                                                                                                                                        • ☰ 13.4. Attributes and methods
                                                                                                                                          • ☰ 13.5. Encapsulation
                                                                                                                                            • ☰ 13.6. Inheritance (basics)
                                                                                                                                              • ☰ 13.7. Simple OOP examples
                                                                                                                                              • ☰ 14. Chapter 14: Automation with Python
                                                                                                                                                • ☰ 14.1. What is automation?
                                                                                                                                                  • ☰ 14.2. Automating simple tasks
                                                                                                                                                    • ☰ 14.3. Working with files and folders
                                                                                                                                                      • ☰ 14.4. Automating text processing
                                                                                                                                                        • ☰ 14.5. Scheduling scripts
                                                                                                                                                          • ☰ 14.6. Practical automation examples
                                                                                                                                                          • ☰ 15. Chapter 15: Web Development with Python
                                                                                                                                                            • ☰ 15.1. How the web works (basic overview)
                                                                                                                                                              • ☰ 15.2. Introduction to Flask
                                                                                                                                                                • ☰ 15.3. Creating a simple web server
                                                                                                                                                                  • ☰ 15.4. Routing and templates
                                                                                                                                                                    • ☰ 15.5. Handling user input (forms)
                                                                                                                                                                      • ☰ 15.6. Very basic APIs
                                                                                                                                                                      • ☰ 16. Chapter 16: Data Science with Python
                                                                                                                                                                        • ☰ 16.1. What is data science?
                                                                                                                                                                          • ☰ 16.2. Working with data
                                                                                                                                                                            • ☰ 16.3. Introduction to NumPy
                                                                                                                                                                              • ☰ 16.4. Introduction to pandas
                                                                                                                                                                                • ☰ 16.5. Data visualization with matplotlib
                                                                                                                                                                                  • ☰ 16.6. Simple data analysis examples
                                                                                                                                                                                  • ☰ 17. Chapter 17: Mini Projects
                                                                                                                                                                                    • ☰ 17.1. Number guessing game
                                                                                                                                                                                      • ☰ 17.2. Simple calculator
                                                                                                                                                                                        • ☰ 17.3. To-do list
                                                                                                                                                                                          • ☰ 17.4. Password generator
                                                                                                                                                                                            • ☰ 17.5. Quiz application
                                                                                                                                                                                              • ☰ 17.6. Small web or data project
                                                                                                                                                                                              • ☰ 18. Chapter 18: Next Steps
                                                                                                                                                                                                • ☰ 18.1. How to practice Python
                                                                                                                                                                                                  • ☰ 18.2. Writing clean and readable code
                                                                                                                                                                                                    • ☰ 18.3. Choosing a specialization
                                                                                                                                                                                                      • ☰ 18.3.1. Web development
                                                                                                                                                                                                        • ☰ 18.3.2. Data science
                                                                                                                                                                                                          • ☰ 18.3.3. Automation
                                                                                                                                                                                                            • ☰ 18.3.4. Software development
                                                                                                                                                                                                            • ☰ 18.4. Learning resources and communities
                                                                                                                                                                                                            • ☰ 19. Appendix
                                                                                                                                                                                                              • ☰ 19.1. Python syntax cheat sheet
                                                                                                                                                                                                                • ☰ 19.2. Common errors and solutions
                                                                                                                                                                                                                  • ☰ 19.3. Glossary of terms