If you’re stuck at home, now is the time to polish your skills. Here are 6 fun Python project ideas to get you started! Before you start on these projects, make sure your basic Python skills are sufficient, for example by following our Python tutorial for beginners.
Create a game
I bet you never considered creating a game with Python. But why not? There are awesome libraries that will help you develop games. So let’s help your kids, your partner, or your colleagues get through this pandemic with a fun game! For this Python project idea, there are several libraries to look at.
Pygame
Pygame is a cross-platform set of Python modules designed to write video games. It includes computer graphics and sound libraries. Here are a few tutorials you can try:
- Making Games with Python & Pygame
- Game development with Pygame
- The official getting started guide (note: as of writing, the site is down so I linked to a “Wayback machine” version instead)
Pyglet
Instead of Pygame, you may also look into Pyglet. It is a Python library for developing games and other visually-rich applications. You can start by following the official documentation.
Panda3D
Panda 3D is a game engine that includes graphics, audio, I/O, collision detection, and other abilities relevant to the creation of 3D games. Its core is written in C++, so it’s very fast. Lucky for us, we can use the library from Python!
Panda3D has been used to create commercial games as well as some open-source ones. If you always wanted to dive into 3D game programming, this is the time. Start with the official manual.
Build a website
This next Python project idea is a little less original, I admit, but it is an essential skill to have! Several frameworks help you build a Python-based website. One of the most well-known is Django. It’s very extensive and can be used to create complex websites. You can start with the official tutorial. It’s excellent.
Another option is Flask. It’s more lightweight and easier to start with while offering enough to create a relatively simple website.
Once you’ve got the basics, here are some ideas to create:
- Your own blog
- A simple online shop
- A shopping list
- A database of recipes, jokes, or inspirational quotes
Create a GUI with Tkinter
Python has a powerful base library to create GUI applications. Many people, including me, use Python mostly for scripting and for backend code. But there are actually quite a few Python GUI applications too!
One thing to note is that tkinter
has been around for a while. Many tutorials you’ll find are written for Python 2. You can quickly recognize these tutorials because they import the module Tkinter (with capital T), like this:
# don't follow tutorials that start with: import Tkinter
While more recent tutorial will use the new, lower-case library name:
# Look for this instead: import tkinter
A nice tutorial to get you started can be found here.
Here are a few ideas you can build once you mastered the basics:
- A To-Do application
- A notes application
- A calculator
- A weather app (see tip #5 as well)
Build a web service
Another useful skill to possess is the ability to create web services using Python. There are several frameworks that make this task super easy. These are the most recommended ones:
- Falcon is completely focused on creating web APIs. It’s very fast.
- FastAPI is also focused on writing APIs and is one of the fastest API frameworks for Python
- Flask is a lightweight web framework, which is also suitable for creating services.
You can pick either. An advantage of Flask is that it’s multi-purpose: you can also use it to create websites.
An idea to get you started is to build a web service that serves jokes, either randomly or by category. For this purpose, I would recommend diving into sqlite3
as well.
Fetch data from the web
Python is ideal for fetching information from the web. There are some terrific libraries that will do all the grunt work for you. I’ll list my top 3 here.
Requests
Requests is a Python HTTP client. It makes web requests really simple. Many people prefer it over the other available options.
Just to show how easy requests
can be, here’s some example code:
import requests r = requests.get('https://api.github.com/user', auth=('user', 'pass')) r.status_code # 200 r.headers['content-type'] # 'application/json; charset=utf8' r.encoding # 'utf-8' r.text # u'{"type":"User"...' r.json() # {u'disk_usage': 368627, u'private_gists': 484, ...}
Scrapy crawler
If you want to fetch more than a couple of fixed URLs, you should look into Scrapy. It can be used to build a full-fledged web spider, that can discover new pages on its own within set limits.
Beautiful soup
Once you’ve pulled some HTML from a website, you need to parse it to get what you actually need. Beautiful Soup is a Python library for pulling data out of HTML and XML files. It is mighty powerful and can handle all kinds of HTML, even if it’s broken.
Python tricks and libraries to get more project ideas
If these Python project ideas are not for you, perhaps you can explore some cool Python tricks and libraries instead. Chances are these will inspire you to come up with even cooler Python project ideas:
- Top 15 Python packages you must try
- 30 Python Language Tricks That Will Make You a Better Coder
- The 22 Most-Used Python Packages in The World in 2021
That’s it! I hope you liked these Python project ideas. Don’t forget to use and create a venv when you install these packages. If you have anything to add, please do so in the comments. I’d love to hear your ideas. Thanks for reading, and happy coding!