Preface
Beginners who've finished a basic programming book or a course often wonder what they should do next. This article titled I know how to program, but I don't know what to program succinctly captures the feeling.
After solving exercises that test your understanding of syntax and common logical problems, working on projects is often recommended as the next step in the programming journey.
Working on projects that'll help you solve real world use cases would be ideal. You'll likely have enough incentive to push through difficulties instead of abandoning the project.
Sometimes though, you just don't know what to work on. Or, you have ideas, but not sure how to implement them, how to break down the project into manageable parts, etc. In such cases, a learning resource focused on projects can help.
This book presents five beginner to intermediate level projects inspired by real world use cases:
- Enhance your CLI experience with a custom Python calculator
- Analyzing poll data from a Reddit comment thread
- Finding typos in plain text and Markdown files
- Creating a GUI for evaluating multiple choice questions
- Square Tic Tac Toe — creating a GUI game with AI
To test your understanding and to make it more interesting, you'll also be presented with exercises at the end of each project. Resources for further exploration are also mentioned throughout the book.
Prerequisites
You should be comfortable with Python syntax and familiar with beginner to intermediate level programming concepts. For example, you should know how to use data types like list
, tuple
, dict
, set
, etc. Features like exceptions, file processing, sorting, comprehensions, generator expressions, etc. Classes, string methods and regular expressions will also be used in this book.
If you are new to programming or Python, I'd highly recommend my comprehensive curated list on Python to get started.
Conventions
- The examples presented here have been tested with Python version 3.9.5 and GNU bash version 5.0.17
- Code snippets that are copy pasted from the Python REPL shell have been modified for presentation purposes. For example, comments to provide context and explanations, blank lines to improve readability and so on.
- A comment with filename will be shown as the first line for program files.
- External links are provided for further exploration throughout the book. They have been chosen with care to provide more detailed resources on those topics as well as resources on related topics.
- The practice_python_projects repo has all the programs and related example files presented in this book, organized by project for convenience.
Acknowledgements
- Python documentation — manuals and tutorials
- /r/learnpython/ and /r/Python/ — helpful forums for Python programmers
- stackoverflow and unix.stackexchange — for getting answers on Python, Bash and other pertinent questions
- tex.stackexchange — for help on pandoc and
tex
related questions - Cover image:
- Programming illustration by Vijay Verma
- command-window, chart, game, network, question and snake icons from svgrepo.com
- LibreOffice Draw — background and title/author text
- Warning and Info icons by Amada44
- pngquant and svgcleaner for optimizing images
- Inkscape for favicon
- mdBook — for web version of the book that you are currently reading
- mdBook-pagetoc — for adding table of contents for each page
- minify-html — for minifying html files
Feedback and Errata
I would highly appreciate if you'd let me know how you felt about this book, it would help to improve this book as well as my future attempts. Also, please do let me know if you spot any error or typo.
Issue Manager: https://github.com/learnbyexample/practice_python_projects/issues
E-mail: learnbyexample.net@gmail.com
Twitter: https://twitter.com/learn_byexample
Author info
Sundeep Agarwal is a lazy being who prefers to work just enough to support his modest lifestyle. He accumulated vast wealth working as a Design Engineer at Analog Devices and retired from the corporate world at the ripe age of twenty-eight. Unfortunately, he squandered his savings within a few years and had to scramble trying to earn a living. Against all odds, selling programming ebooks saved his lazy self from having to look for a job again. He can now afford all the fantasy ebooks he wants to read and spends unhealthy amount of time browsing the internet.
When the creative muse strikes, he can be found working on yet another programming ebook (which invariably ends up having at least one example with regular expressions). Researching materials for his ebooks and everyday social media usage drowned his bookmarks, so he maintains curated resource lists for sanity sake. He is thankful for free learning resources and open source tools. His own contributions can be found at https://github.com/learnbyexample.
List of books: https://learnbyexample.github.io/books/
License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License
Code snippets are available under MIT License
Images mentioned in Acknowledgements section above are available under original licenses.
Book version
1.0
See Version_changes.md to track changes across book versions.