25 Python Projects for Beginners – Easy Ideas to Get Started Coding Python

Jessica Wilkins

The best way to learn a new programming language is to build projects with it.

I have created a list of 25 beginner friendly project tutorials in Python.

My advice for tutorials would be to watch the video, build the project, break it apart and rebuild it your own way. Experiment with adding new features or using different methods.

That will test if you have really learned the concepts or not.

You can click on any of the projects listed below to jump to that section of the article.

If you are not familiar with the basics of Python, then I would suggest watching this beginner freeCodeCamp Python tutorial .

Python Projects You Can Build

  • Guess the Number Game (computer)
  • Guess the Number Game (user)
  • Rock, paper, scissors
  • Countdown Timer
  • Password Generator
  • QR code encoder / decoder
  • Tic-Tac-Toe
  • Tic-Tac-Toe AI
  • Binary Search
  • Minesweeper
  • Sudoku Solver
  • Photo manipulation in Python
  • Markov Chain Text Composer
  • Connect Four
  • Online Multiplayer Game
  • Web Scraping Program
  • Bulk file renamer
  • Weather Program

Code a Discord Bot with Python - Host for Free in the Cloud

  • Space invaders game

Mad libs Python Project

In this Kylie Ying tutorial, you will learn how to get input from the user, work with f-strings, and see your results printed to the console.

This is a great starter project to get comfortable doing string concatenation in Python.

Guess the Number Game Python Project (computer)

In this Kylie Ying tutorial, you will learn how to work with Python's random module , build functions, work with while loops and conditionals, and get user input.

Guess the Number Game Python Project (user)

In this Kylie Ying tutorial, you will build a guessing game where the computer has to guess the correct number. You will work with Python's random module , build functions, work with while loops and conditionals, and get user input.

Rock, paper, scissors Python Project

In this Kylie Ying tutorial , you will work with random.choice() , if statements, and getting user input. This is a great project to help you build on the fundamentals like conditionals and functions.

Hangman Python Project

In this Kylie Ying tutorial, you will learn how to work with dictionaries, lists, and nested if statements. You will also learn how to work with the string and random Python modules.

Countdown Timer Python Project

In this Code With Tomi tutorial , you will learn how to build a countdown timer using the time Python module. This is a great beginner project to get you used to working with while loops in Python.

Password Generator Python Project

In this Code With Tomi tutorial , you will learn how to build a random password generator. You will collect data from the user on the number of passwords and their lengths and output a collection of passwords with random characters.

This project will give you more practice working with for loops and the random Python module.

QR code encoder / decoder Python Project

In this Code With Tomi tutorial , you will learn how to create your own QR codes and encode/decode information from them. This project uses the qrcode library.

This is a great project for beginners to get comfortable working with and installing different Python modules.

Tic-Tac-Toe Python Project

In this Kylie Ying tutorial, you will learn how to build a tic-tac-toe game with various players in the command line. You will learn how to work with Python's time and math modules as well as get continual practice with nested if statements.

Tic-Tac-Toe AI Python Project

In this Kylie Ying tutorial, you will learn how to build a tic-tac-toe game where the computer never loses. This project utilizes the minimax algorithm which is a recursive algorithm used for decision making.

Binary Search Python Project

In this Kylie Ying tutorial, you will learn how to implement the divide and conquer algorithm called binary search. This is a common searching algorithm which comes up in job interviews, which is why it is important to know how to implement it in code.

Minesweeper Python Project

In this Kylie Ying tutorial, you will build the classic minesweeper game in the command line. This project focuses on recursion and classes.

Sudoku Solver Python Project

In this Kylie Ying tutorial, you will learn how to build a sudoku solver which utilizes the backtracking technique. Backtracking is a recursive technique that searches for every possible combination to help solve the problem.

Photo Manipulation in Python Project

In this Kylie Ying tutorial, you will learn how to create an image filter and change the contrast, brightness, and blur of images. Before starting the project, you will need to download the starter files .

Markov Chain Text Composer Python Project

In this Kylie Ying tutorial, you will learn about the Markov chain graph model and how it can be applied the relationship of song lyrics. This project is a great introduction into artificial intelligence in Python.

Pong Python Project

In this Christian Thompson tutorial , you will learn how to recreate the classic pong game in Python. You will be working with the os and turtle Python modules which are great for creating graphics for games.

Snake Python Project

In this Tech with Tim tutorial, you will learn how to recreate the classic snake game in Python. This project uses Object-oriented programming and Pygame which is a popular Python module for creating games.

Connect Four Python Project

In this Keith Galli tutorial, you will learn how to build the classic connect four game. This project utilizes the numpy , math , pygame and sys Python modules.

This project is great if you have already built some smaller beginner Python projects. But if you haven't built any Python projects, then I would highly suggest starting with one of the earlier projects on the list and working your way up to this one.

Tetris Python Project

In this Tech with Tim tutorial, you will learn how to recreate the classic Tetris game. This project utilizes Pygame and is great for beginner developers to take their skills to the next level.

Online Multiplayer Game Python Project

In this Tech with Tim tutorial, you will learn how to build an online multiplayer game where you can play with anyone around the world. This project is a great introduction to working with sockets, networking, and Pygame.

Web Scraping Program Python Project

In this Code With Tomi tutorial , you will learn how to ask for user input for a GitHub user link and output the profile image link through web scraping. Web scraping is a technique that collects data from a web page.

Bulk File Re-namer Python Project

In this Code With Tomi tutorial , you will learn how to build a program that can go into any folder on your computer and rename all of the files based on the conditions set in your Python code.

Weather Program Python Project

In this Code With Tomi tutorial , you will learn how to build a program that collects user data on a specific location and outputs the weather details of that provided location. This is a great project to start learning how to get data from API's.

In this Beau Carnes tutorial , you will learn how to build your own bot that works in Discord which is a platform where people can come together and chat online. This project will teach you how to work with the Discord API and Replit IDE.

After this video was released, Replit changed how you can store your environments variables in your program. Please read through this tutorial on how to properly store environment variables in Replit.

Space Invaders Game Python Project

In this buildwithpython tutorial , you will learn how to build a space invaders game using Pygame. You will learn a lot of basics in game development like game loops, collision detection, key press events, and more.

Read more posts .

If this article was helpful, share it .

Learn to code for free. freeCodeCamp's open source curriculum has helped more than 40,000 people get jobs as developers. Get started

Python Geeks

Learn Python Programming from Scratch

  • Python Projects

70+ Python Projects for Beginners [Source Code Included]

Boost Your Career with Our Placement-ready Courses – ENroll Now

Python is an incredibly powerful programming language, and it is becoming more popular every day. With its flexibility, it is no wonder that Python is used in so many different projects.

With so many options, it can take time to figure out where to start. So if you are looking for some great Python projects to get you started, here are the 70+ best python projects out there!

Master Python with live projects will be your best investment.

Work on Real-time Projects

  • Mad Libs Generator in Python
  • Python Number Guessing Game
  • Countdown Timer in Python
  • Python Password Generator
  • Create Contact Book using Python
  • Binary search algorithm in Python
  • Create Desktop Notifier App in Python
  • Python Website Blocker Project
  • Web Scraping Python Project
  • Python URL Shortener
  • Python Twitter Bot
  • Python Reddit Bot
  • Python Discord Bot
  • Crypto App using Python
  • Sorting Method in Python
  • Create Interactive Quiz using Python
  • Develop Counter App using Python
  • Web Browser Python Project
  • Build Notes App in Python
  • Create Typing Tester using Python
  • Python Wikipedia Explorer
  • Python Stock Market Prediction App
  • Create Image Recognition App in Python
  • Design Price Prediction Model in Python
  • Interactive Map in Python
  • Temperature Converter Project in Python
  • Measurement Converter Project in Python
  • Python Prison Break Project
  • Star Wars Survey Python Project
  • Netflix Data Analysis in Python
  • Bulk File Renamer in Python
  • Python Weather Program
  • Markov Text Chain Composer Project
  • Pong Game in Python
  • Connect Four Python Project
  • Python Tetris Game Project
  • Online Multiplayer Game in Python
  • Python Minesweeper Game
  • Flames Game in Python
  • Python 2048 Game
  • Python Snake Game
  • Build Space Invaders Game in Python
  • Create Sudoku Solver using Python
  • Python Tic-Tac-Toe Game
  • Dice Rolling Simulator using Python
  • Hangman Game in Python
  • Rock Paper Scissors Game in Python
  • Create Text Adventure Game in Python
  • Create Memory Puzzle Game in Python
  • Photo Manipulation using Python
  • Python Calculator
  • Python QR Code Encoder/ Decoder Project
  • Video to Audio Converter Python Project
  • Python YouTube Downloader
  • Visualise a Solar System using Python
  • Shutdown, Restart and Logout Computer with Python
  • Shop Management System Python Project
  • Voice Assistant Python Project
  • Convert PDF File Text to AudioBook & Speech to PDF using Python
  • Extract Song Lyrics in Python
  • Website Connectivity Checker Python Project
  • Python Library Management System
  • Convert Text to Speech and Speech to Text with Python
  • Expense Tracker Python Project
  • Screen Recorder Python Project
  • Python Currency Converter
  • Music Player Python Project
  • Language Translator Python Project
  • Python To-Do List
  • Python Text Editor
  • Python Chatbot Project
  • Sentiment Analysis Model using Python

Python Project for Beginners

1. mad libs generator in python.

Python Project Idea – Mad Libs is a game where players have to put random words in the blanks of a story. The Mad Libs Generator is a Python project that allows users to generate their own Mad Libs stories.

This project will require you to use basic Python programming constructs such as variables, loops, and conditionals. It will also require you to use string manipulation methods to fill in the blanks in the template story. It is perfect for beginners who are just starting to learn Python programming. At the end of this project, you will have a basic understanding of using Python to create a simple but useful program.

Source Code – Mad Libs Generator in Python

2. Python Number Guessing Game

Python Project Idea – This is a fun little project that I like to do in my spare time. It is a number-guessing game written in Python. The basic idea is to have the computer produce a random number between 1 and 100 and then have the user try to guess it. If the user guesses correctly, they win! If not, the computer tells them whether their guess was too high or too low, and they get another chance. It is a simple concept but a lot of fun to play.

Source Code – Number Guessing Game

3. Countdown Timer in Python

Python Project Idea – A countdown timer is a useful tool for keeping track of time. In this project, we will create a countdown timer using Python. We will first create a function to take time in seconds and print it out in a formatted string. We will then use this function to create a countdown timer.

The countdown timer will start at a given time and count down to zero. At each second, it will print out the remaining time. When the timer reaches zero, it will print out a message saying, “Time’s up!.” This project is a great way to learn about working with time in Python. It is also a useful tool that you can use in your projects.

Source Code – Countdown Timer in Python

4. Python Password Generator

Python Project Idea – Python is a versatile language to create all sorts of applications, including a password generator. This project will walk you through creating a password generator with Python. You will learn how to generate passwords of different lengths and complexity, as well as how to store them securely. This project is a great way to learn more about Python and practise your coding skills.

Source Code – Password Generator in Python

5. Create Contact Book using Python

Python Project Idea – A contact book is a handy tool to keep all your contacts in one place. This python project will allow you to create a contact book and add, edit, and delete contacts. In addition, you’ll be able to view all your contacts and their details in one place. This project is perfect for anyone who wants to keep their contacts organised and accessible.

Source Code – Contact Book using Python

6. Binary search algorithm in Python

Python Project – A binary search algorithm finds an item in a sorted array in O(log(n)) time. The binary search algorithm can be implemented in Python using a simple while loop.

The array must first be sorted in ascending order to perform a binary search. Then, the algorithm will search the array for the target value by repeatedly dividing the search array in half until the target value is found. If the target value is not found in the array, the algorithm will return -1.

A binary search algorithm is a tool that can efficiently search large arrays. When implemented in Python, the binary search algorithm can quickly find an item in a sorted array.

Source Code – Binary search algorithm in Python

7. Create Desktop Notifier App in Python

Python Project – A desktop notifier app can keep track of your to-do list and ensure you don’t miss any important deadlines. This Python project involves building a simple app that displays notifications on your desktop when a task is due. It will help you learn the Python requests module to fetch data from a remote API, how to use the Python Pillow module to generate images, and how to use the Python pynotifier module to display notifications. By the end of this project, you’ll have a useful tool that you can use to stay organised.

8. Python Website Blocker Project

Python Project – Website blocking is a process of preventing users from accessing certain websites. This can be done to prevent access to sites that contain malware or phishing content.

There are different ways to block websites in Python. One popular method is to use a Python module called host block. This module provides several features for blocking websites, including blocking specific URLs or domains and redirecting blocked URLs to a custom page.

Another popular method for blocking websites in Python is to use the urllib2 module. This module provides several functions for working with URLs, including blocking specific URLs.

9. Web Scraping Python Project

Python Project Idea – Web scraping means extracting data from websites. It can be done manually, but it is usually done using special software. Python is a popular language for building web scraping programs because it is powerful and easy to use. There are many libraries and tools available for web scraping in Python.

10. Python URL Shortener

Python Project Idea – A URL shortener is a web application that takes long URLs and converts them into short, easy-to-remember URLs. The shortened URL can be used by anyone who wants to access the original URL.

Many URL shorteners are available online, but you can also create your own URL shortener using the Python programming language. You will need to import the Flask and requests modules in your Python script. Flask will be used to create the web application, and requests will be used to send requests to the Bitly API.

Beginner Python Project Examples

11. python twitter bot.

Python Project Idea – A Twitter bot can tweet and retweet on behalf of its user. You can use the tweepy library to interface with the Twitter API. The time, random, and os libraries will also help with some of the bot’s functionality.

12. Python Reddit Bot

Python Project Idea – A Reddit bot login to Reddit parses comments and posts and responds accordingly. The bot will be used to automatically post new content from a specific subreddit to a Discord channel. You can use the PRAW (Python Reddit API Wrapper) library to interact with the Reddit API. This is a complex project that will require time and effort.

13. Python Discord Bot

Python Project – The discord bot python project is an interesting and unique project that can be used to create a bot for the popular chat application, Discord. This project requires a bit of knowledge in Python programming language and will also be using the Discord API. In addition, the project will be using the discord.py library.

You will first need to create a Discord account and a Discord application. After that, the project will need to get the Discord API key and use it to create a bot. The bot will then need to be added to a Discord server. The project will then need to code the bot and make it do different things, such as responding to messages, playing music, etc.

14. Crypto App using Python

Python Project Idea – The crypto app python project is a tool allowing users to encrypt and decrypt messages using the AES256 encryption algorithm. It also provides a user-friendly interface for managing keys and encrypting/decrypting messages.

15. Sorting Method in Python

Python Project Idea – The sorting method python project is a project that enables you to sort a list of items in ascending or descending order. This project is very useful for those who want to organise their data in a particular order.

16. Create Interactive Quiz using Python

Python Project Idea – Interactive quiz python project is a web-based Quiz application that allows users to answer questions in a quiz format and receive feedback on their answers. In addition, the application keeps track of the user’s progress and allows them to look at their answers at the end of the quiz.

17. Develop Counter App using Python

Python Project Idea – The Counter app is a Python project that allows users to keep track of the number of times they perform a given task. For example, users can use the app to count the number of times they brush their teeth or walk their dogs. The app can be used for any task the user wants to track.

18. Web Browser Python Project

Python Project Idea – The web browser python project is a project that allows users to browse the internet using the python programming language. The project provides a web browser interface that is easy to use and allows users to surf the web without installing any additional software. The project is open source and is available for free.

Source Code – Web Browser in Python

19. Build Notes App in Python

Python Project Idea – The Notes App Python Project is a simple command line application that allows users to create and manage notes. The project is written in Python and uses the built-in sqlite3 module to store data.

The application has two main features: creating and managing notes. To create a note, the user must specify a title and body. The body of the note can be either plain text or Markdown. Once a note is created, the user can view, edit, or delete it.

20. Create Typing Tester using Python

Python Project Idea – The Type Tester Python Project is a set of scripts that will help you to test and debug your fonts. It is designed to be in conjunction with font files, so you will need to have the font files installed on your system.

This project is not meant to replace a typeface designer or typographer. It is only meant to help identify inconsistencies in the font file and then provide the user with suggestions about how to fix them.

Source Code – Typing Tester in Python

21. Python Wikipedia Explorer

Python Project Idea – The Wikipedia Explore Python Project is a project that aims to teach people how to code in Python. This project is not a course but an interactive and exploratory way of learning Python. It provides various exercises that help you learn the basics of Python.

The project also has a section for learners who have already learned some basics of coding and want to explore more advanced concepts.

Easy Python Projects for Aspiring Developers

It’s time to work on basic Python projects

22. Python Stock Market Prediction App

Python Project – A Python project for a stock market prediction app is an exciting opportunity to learn about financial markets. The project aims to develop a Python library that can predict the prices of stocks in the future based on their historical prices. The library will use linear regression analysis to find a relationship between past and future prices.

23. Create Image Recognition App in Python

Python Project Idea – Image recognition is a technology that will make our lives easier. The project aims to create an image recognition app using Python. This app will use computer vision and image processing algorithms to recognise objects in images and then provide the user with the object’s name. This technology has many applications, such as recognising faces and identifying people in images or videos, recognising scenes and objects in images or videos, identifying text in images or videos, etc.

24. Design Price Prediction Model in Python

Python Project – A price prediction model is a mathematical model that predicts the price of an item based on certain parameters. Python is a programming language used to create these models. The following are some ways to use it:

  • To create games
  • To create websites
  • To make animations
  • To program robots or drones

25. Interactive Map in Python

Python Project – The interactive map python project is an open-source project which aims to provide a framework for developers to create interactive maps. It has been developed by the Open Source Geospatial Foundation.

It is a Python library that works with the ArcGIS API for Python and can also be used with other GIS software. The Interactive Map Python Project provides a framework for developers to create interactive maps and has been developed by the Open Source Geospatial Foundation.

26. Temperature Converter Project in Python

Python Project – This project aims to be a temperature converter for people living in Celsius or Fahrenheit countries. It converts the temperature from Fahrenheit to Celsius and vice versa.

27. Measurement Converter Project in Python

Python Project – The measurement converter python project is a simple application that converts between various units of measure. It has been created to help people who need to convert between different measurements but don’t know how to do it. The project is open-source and free to use.

This project was created in order to provide the user with a simple application that can convert one unit of measure to another. The measurement converter python project is open-source and free for anyone who needs it.

Source Code: Python Weight Converter Project

28. Python Prison Break Project

Python Project Idea – The Prison Break Python Project is an open-source project that aims to provide a library of code for people who want to write programs that can break out of prisons. It is a system that can be used to break into any password-protected computer. The system is a Python library designed to use brute force attacks to guess the password.

29. Star Wars Survey Python Project

Python Project – The star wars survey project in Python is a framework for creating surveys. It is an open-source Django application that provides a framework for building surveys. The project has been created to make it easy to build a questionnaire that can be submitted to respondents and then analysed using statistical software such as R or Stata.

30. Netflix Data Analysis in Python

Python Project – The company has a history of using machine learning to improve its services and recently released a project called the Netflix Analysis Project in Python. This project aims to provide an intuitive interface for data exploration and analysis by using tools from the Python ecosystem.

The project consists of three modules: Data Exploration Toolkit (DET), Data Analysis Toolkit (DAT), and Visualization Toolkit (VIT). All three modules are built on Jupyter notebooks with the JupyterLab extension.

31. Bulk File Renamer in Python

Python Project – The bulk file renamer project in Python renames files with a given prefix. It works by analysing the directory for files with the given prefix and then renaming them with the specified suffix. This project can be helpful when you want to organise your media library or if you are working on a large project and need to rename all your images.

32. Python Weather Program

Python Project – The weather program project in Python is a tool that provides the user with a clear interface to display the current temperature and forecast of the weather. Using this program, you can find weather details in different parts of the world.

The program takes in input from various sources, such as Google Maps, Yahoo Weather, and the US National Weather Service.

It then displays this data on its interface for easy reading. It also has an option for users to share their location with friends or family so that they can see what the current weather is like from their perspective.

Source Code – Live Weather Notifications using Python

33. Markov Text Chain Composer Project

Python Project – Markov Text Chain Composer is a project in Python that uses machine learning to generate new text based on existing text. It works by looking at a body of text and using the patterns it finds to create new text with the same style. So if you have a book written in a certain way, the project can generate new sentences that sound like they came from the same book.

Cool Python Projects for Game Developers

34. pong game in python.

Python Project – Pong is a game written in Python using the PyGame library. It is a classic two-player game where players control a paddle and hit the ball back and forth. The first player who misses the ball loses! Making a Pong project in Python means writing code to run the game.

Source Code – Pong Game in Python

35. Connect Four Python Project

Python Project – Connect Four is a game where you try to line up four pieces in a row on a board. With a Python project, you can use computer programming to create a version of the game. This version will be able to track how many pieces each player has, what colour pieces the player has, how many pieces are left to place, and when somebody wins the game.

36. Python Tetris Game Project

Python Project – A Tetris project in Python is one of the popular game python projects. It is a computer game that someone can write in Python. It involves writing code to make pieces of different shapes fall from the top of the screen, and the goal is to fit them together, so they make a complete row. If you can do that, the row of pieces will disappear, and you can keep playing.

37. Online Multiplayer Game in Python

Python Project Idea – A Python Online Multiplayer Game project is a computer program that allows people to play games together over the internet. It could be a card game, a racing game, a board game or whatever game people want to play. The programming language Python is used to create this type of game so that people can have fun interacting with each other online.

38. Python Minesweeper Game

Python Project – Minesweeper is a game where you must find all the hidden ‘mines’ (or bombs) on a grid without clicking on any of them. To do a Minesweeper project in Python, you’ll have to write a program that will create the game and allow you to play it by clicking on the squares and trying to figure out which ones have hidden bombs. If you get it wrong, you lose the game!

39. Flames Game in Python

Python Project Idea – Flames Game is a Python project that helps two people determine if they are meant to be together. First, you give it your name and your crush’s name, and it generates a word made up of the letters from both of your names. Then, it gives you instructions on counting the letters until you are left with only one letter, which tells you if you are compatible or not.

Source Code – Flames Game in Python

40. Python 2048 Game

Python Project Idea – The 2048 project is a game written in Python where a player moves tiles around on the board to try to add them up to 2048. Each move adds a new tile to the board with a value of two or four. The goal is to keep adding tiles and moving them around to get the sum of tiles on the board to reach 2048.

python 2048 project output

Source Code – 2048 Game in Python

41. Python Snake Game

Python Project – The Snake Python Project is a project to create a comprehensive database of information on snakes. The project is open to anyone who wishes to contribute, and all contributions are welcome. The project is still in the initial stages, but it is predicted to eventually become a valuable resource for snake enthusiasts and experts alike.

Source Code – Snake Game in Python

42. Build Space Invaders Game in Python

Python Project Idea – Space Invaders is a classic video game from the 1980s. In this game, the player controls a ship at the screen’s bottom and must destroy the waves of aliens attacking from the top.

This project will involve creating a Space Invaders game in Python. We will start by creating a basic game engine, then add the player ship, aliens, and other features. Finally, the project will be completed with a high-score system and some sound effects.

43. Create Sudoku Solver using Python

Python Project – The challenge of creating a Sudoku solver program is to take an arbitrary Sudoku puzzle and generate a solution. This can be accomplished by exhaustively searching through all possible permutations of the digits until the correct solution is found.

The first step is to input the Sudoku puzzle to create a Sudoku solver program. The program will then generate all possible permutations of the digits 1-9 and check to see if each permutation satisfies the constraints of the Sudoku puzzle. If a permutation satisfies the constraints, the program will output the permutation as the solution to the Sudoku puzzle.

python sudoku solver output

Source Code – Sudoku Solver using Python

44. Python Tic-Tac-Toe Game

Python Project Idea – The tic-tac-toe python project is an excellent way to learn how to code in Python. The goal is to create a functioning tic-tac-toe game that two people can play. The project is simple to code and can be used to teach the basics of coding to beginners.

The project can also be used to teach more advanced concepts to experienced coders. The project is a great way to learn about coding in Python and can be used to teach others how to code in Python.

Source Code – Tic-Tac-Toe Game in Python

45. Dice Rolling Simulator using Python

Python Project Idea – Python is a versatile language you can use to create programs, including a dice-rolling simulator. This project will walk you through creating a dice-rolling simulator program in Python.

We will start by creating a basic program that simulates rolling a single die. Then, add a few features to make the program more realistic, like rolling multiple dice at once. Finally, add a graphical user interface (GUI) so that users can interact with the program more easily.

Creating a basic dice-rolling simulator is a great way to learn Python’s programming basics. At the end of this project, you will have a program you can use to play all sorts of dice games. So let’s get started!

Source Code – Dice Rolling Simulator in Python

46. Hangman Game in Python

Python Project – This is a python project that implements the game of hangman. The player is given a specific number of chances to guess the word, and if they are unsuccessful, they are “hanged”. The project uses a simple text-based interface.

Source Code – Hangman Game in Python

47. Rock Paper Scissors Game in Python

Python Project – Rock Paper Scissors is a simple game you can play with a friend. The game is played by each player choosing one of rock, paper, or scissors, and then the players compare their choices. It is a draw if both players have chosen the same thing. Otherwise, the winner is the player who has chosen the winning hand (rock beats scissors, paper beats rock, scissors beats paper). This project is a fun and easy way for people to learn about Python.

Source Code – Rock Paper Scissors Game in Python

48. Create Text Adventure Game in Python

Python Project Idea – The text adventure game is a game where the player uses text commands to control the character and progress through the story. The game is written in Python programming language and designed to run on the command line. The project is open source, meaning anyone can contribute to the game’s development.

49. Create Memory Puzzle Game in Python

Python Project – A Memory Puzzle Game is an interactive game using Python programming to help you remember things. It’s like a game of Concentration where you have to match two cards with the same picture. You can make the game harder by increasing the number of cards or easier by decreasing the number of cards. It’s a fun way to practise your coding skills!

Source Code – Memory Puzzle Game in Python

Python Project for Final Year Students

50. photo manipulation using python.

Python Project Idea – Photo manipulation is when you use a computer program to edit photos. For example, in a Python project, you would write computer code in the Python language to manipulate photos. This could include changing the size or brightness of the photo, cropping it, adding text or objects, or removing certain elements.

51. Python Calculator

Python Project Idea – The Calculator Project in Python is a fun way to learn to program. It’s a project where you create your own calculator that can do essential functions like adding, subtracting, and multiplying numbers. You can program the calculator to do more advanced maths and even create your own calculator functions. It’s a great way to learn Python programming and develop your skills.

python project calculator output

Source Code – Calculator in Python

52. Python QR Code Encoder/ Decoder Project

Python Project – This project is where you write code that can create a special type of barcode called a QR Code. Then, you can also write code that can scan and decode these barcodes and figure out what information is inside them. This is useful for quickly scanning a product in a store and getting information about it.

Source Code – Generate QR Code using Python

53. Video to Audio Converter Python Project

Python Project – A Video to Audio Converter project in Python is a way to take a video file and turn it into an audio file. It is a type of computer program written in the Python programming language that takes a video file and converts it into an audio file you can listen to or share with others.

Source Code – Video to Audio Converter in Python

54. Python YouTube Downloader

Python Project – A YouTube Downloader project in Python is a program written in the python language that can be used to download videos from YouTube onto your computer. It will use code to search for videos and then download them directly to your computer, so you can watch them later when you don’t have an internet connection.

Source Code – YouTube Downloader in Python

55. Visualise a Solar System using Python

Python Project – This project is a way to use code to create a picture of a solar system on a computer screen. It uses loops and data sets to draw the planets and their orbits, then add the sun and other stars to the system. It’s a fun project that shows how coding can be used to create something beautiful.

python project solar system output

Source Code – Visualise a Solar System using Python

56. Shutdown, Restart and Logout Computer with Python

Python Project – This project is a way to use the Python programming language to make a program that lets you shut down, restart, or log out of your computer. It will use commands to tell the computer what to do. For instance, if you want to shut down your computer, the program will send a command to the computer telling it to shut down.

Source Code – Shutdown, Restart and Logout Computer with Python

57. Shop Management System Python Project

Python Project – A Shop Management System project in Python is a computer program that helps people who run shops track and organise their stock. It can help them keep track of what items they have in their shop, how much money they’re making from selling items, and how much money they need to buy more things. Python is the programming language used to create this project.

Source Code – Shop Management System in Python

58. Voice Assistant Python Project

Python Project – Voice Assistant project in Python teaches a computer to understand and respond to speech. You can use the Python programming language to create a program that can understand and answer questions or commands you give using your voice. With this project, you can use your voice to control your computer, play music, or search the internet.

Source Code – Voice Assistant in Python

59. Convert PDF File Text to AudioBook and speech to PDF using Python

Python Project – This project is about using Python, a computer programming language, to take text from a PDF document and turn it into an audiobook or to take speech and turn it into a PDF document. It’s like using a computer to listen to a book or type out what someone said into a PDF.

Source Code – PDF File Text to AudioBook using Python

60. Extract Song Lyrics in Python

Python Project – The Extract Song Lyrics project in Python is a computer program that can search the internet and find the words to any song. So it can help you learn the lyrics to your favourite songs without having to look them up or memorise them. Instead, you type in the song’s name, and the program will do the rest!

Source Code – Extract Song Lyrics in Python

61. Website Connectivity Checker Python Project

Python Project – The Website Connectivity Checker project in Python is a program that checks to ensure websites are working properly and can easily be accessed. It can look at websites from different parts of the world and ensure they respond quickly.

Source Code – Website Connectivity Checker in Python

Python Project Ideas –  Advanced Level

62. python library management system.

Python Project – The Library Management System project in Python is a program that helps librarians manage their library by keeping track of the books in the library and the people who borrow them. It can also help keep track of the due dates and fines for books that are overdue. It makes it easier for borrowers to find books they want and for librarians to ensure books are returned on time.

library management system python project output

Source Code – Library Management System in Python

63. Convert Text to Speech and Speech to Text with Python

Python Project Idea – This project is a way of using programming to take written words and convert them into spoken words or take spoken words and convert them into written words. So, for example, it can make talking robots or allow people to type messages without typing them out.

Source Code – Python Text to Speech and Speech to Text Converter Project

64. Expense Tracker Python Project

Python Project Idea – The expense tracker project in Python helps you track how much money you are spending. It keeps a record of your spending and lets you figure out where you can save money. It can also give you advice on how to manage your finances better.

Source Code – Expense Tracker in Python

65. Screen Recorder Python Project

Python Project – The Screen Recorder Project in Python is a program that allows you to record the screen of your computer and save it as a video file. It’s like making a movie of what you’re doing on your computer, so you can watch it later or show it to friends.

Source Code – Screen Recorder in Python

66. Python Currency Converter

Python Project – The Currency Converter Project is one of the best python projects for beginners. It is a program that can convert an amount of money from one currency to another. So, if you had $100 in US Dollars and wanted to see how much it was worth in Euros, you could use the Currency Converter Project to find out.

Source Code – Currency Converter in Python

67. Music Player Python Project

Python Project Idea – The Music Player Project in Python is a project where you can create a program that can play music, like a jukebox. It can store a list of songs and let you choose which one to play. You can also create controls like ‘stop’, ‘pause’ and ‘play’ to control the music.

Source Code – Music Player in Python

68. Language Translator Python Project

Python Project – The Language Translator project is a way to create a program that can translate words and phrases from one language to another. You can use it to help people who don’t speak the same language understand each other. It’s like a human translator, but a computer does it.

Source Code – Language Translator in Python

69. Python To-Do List

Python Project Idea – The To-Do List project in Python is a program that you can use to keep track of tasks you have to do. With this project, you can write down the things that need to be done and then ‘tick’ them off the list when they are complete. It’s a great way to stay organised and ensure nothing is forgotten.

Source Code – To-Do List in Python 

70. Python Text Editor

Python Project Idea – The Text Editor project helps you create a computer program to write and edit text. You can use it to write stories, take notes, or do whatever you need to do with text! It’s like a program that acts like a word processor, but it’s written in Python code.

Source Code – Text Editor in Python

71. Python Chatbot Project

Python Project Idea – Chatbots are a type of AI programmed to communicate with human beings. The chatbot project in this section will teach you to build a chatbot using Python. The first step is to install the Python programming language on your computer and then create a new folder for your project. You will need many libraries, including python-dateutil, python-requests, GoogleMaps, and pytz.

72. Sentiment Analysis Model using Python

Python Project Idea – Sentiment analysis models are a classification type that analyses a given text’s sentiment. A sentiment analysis model can be used in applications such as social media, customer feedback, and even live-chat interfaces. It aims to create an API that will support sentiment analysis through Python.

Python Projects – Summary

As we have seen above, these are the top 70+ python projects. They are simple and fun python projects through which you can learn Python programming. So, choose a project you find interesting and start programming.

If you are Happy with PythonGeeks, do not forget to make us happy with your positive feedback on Google | Facebook

Tags: beginner python projects beginners python projects beginning python projects mini python projects python project for college python project ideas python projects python projects beginners Python Projects for beginners Python projects for final year students python projects for graduation Python projects for students python projects source code python projects with source code real-time python projects

16 Responses

  • Comments 16
  • Pingbacks 0

it was good i need u r code

Great work indeed. I am trying to develop a mdi app with python tkinter, composed of several source codes. Is there any one in your list ? If not ,it world be great if you add one thanks

12th Project

Thank you for codes

hello welcome the project

Hello Welcome to the technical world !!

Great,I’m enjoying, exploring and learning at the same time.thank you

very useful

it is very usefull

i want to source code python

Sweet can’t wait to start !!!

It helped me a lot so thank you.

I want to develop a python code. But i don’t know the alphabets also. so please understand and help me

Very Good Keep it up bro!

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Save my name, email, and website in this browser for the next time I comment.

courses

Python Programming

Practice Python Exercises and Challenges with Solutions

Free Coding Exercises for Python Developers. Exercises cover Python Basics , Data structure , to Data analytics . As of now, this page contains 18 Exercises.

What included in these Python Exercises?

Each exercise contains specific Python topic questions you need to practice and solve. These free exercises are nothing but Python assignments for the practice where you need to solve different programs and challenges.

  • All exercises are tested on Python 3.
  • Each exercise has 10-20 Questions.
  • The solution is provided for every question.
  • Practice each Exercise in Online Code Editor

These Python programming exercises are suitable for all Python developers. If you are a beginner, you will have a better understanding of Python after solving these exercises. Below is the list of exercises.

Select the exercise you want to solve .

Basic Exercise for Beginners

Practice and Quickly learn Python’s necessary skills by solving simple questions and problems.

Topics : Variables, Operators, Loops, String, Numbers, List

Python Input and Output Exercise

Solve input and output operations in Python. Also, we practice file handling.

Topics : print() and input() , File I/O

Python Loop Exercise

This Python loop exercise aims to help developers to practice branching and Looping techniques in Python.

Topics : If-else statements, loop, and while loop.

Python Functions Exercise

Practice how to create a function, nested functions, and use the function arguments effectively in Python by solving different questions.

Topics : Functions arguments, built-in functions.

Python String Exercise

Solve Python String exercise to learn and practice String operations and manipulations.

Python Data Structure Exercise

Practice widely used Python types such as List, Set, Dictionary, and Tuple operations in Python

Python List Exercise

This Python list exercise aims to help Python developers to learn and practice list operations.

Python Dictionary Exercise

This Python dictionary exercise aims to help Python developers to learn and practice dictionary operations.

Python Set Exercise

This exercise aims to help Python developers to learn and practice set operations.

Python Tuple Exercise

This exercise aims to help Python developers to learn and practice tuple operations.

Python Date and Time Exercise

This exercise aims to help Python developers to learn and practice DateTime and timestamp questions and problems.

Topics : Date, time, DateTime, Calendar.

Python OOP Exercise

This Python Object-oriented programming (OOP) exercise aims to help Python developers to learn and practice OOP concepts.

Topics : Object, Classes, Inheritance

Python JSON Exercise

Practice and Learn JSON creation, manipulation, Encoding, Decoding, and parsing using Python

Python NumPy Exercise

Practice NumPy questions such as Array manipulations, numeric ranges, Slicing, indexing, Searching, Sorting, and splitting, and more.

Python Pandas Exercise

Practice Data Analysis using Python Pandas. Practice Data-frame, Data selection, group-by, Series, sorting, searching, and statistics.

Python Matplotlib Exercise

Practice Data visualization using Python Matplotlib. Line plot, Style properties, multi-line plot, scatter plot, bar chart, histogram, Pie chart, Subplot, stack plot.

Random Data Generation Exercise

Practice and Learn the various techniques to generate random data in Python.

Topics : random module, secrets module, UUID module

Python Database Exercise

Practice Python database programming skills by solving the questions step by step.

Use any of the MySQL, PostgreSQL, SQLite to solve the exercise

Exercises for Intermediate developers

The following practice questions are for intermediate Python developers.

If you have not solved the above exercises, please complete them to understand and practice each topic in detail. After that, you can solve the below questions quickly.

Exercise 1: Reverse each word of a string

Expected Output

  • Use the split() method to split a string into a list of words.
  • Reverse each word from a list
  • finally, use the join() function to convert a list into a string

Steps to solve this question :

  • Split the given string into a list of words using the split() method
  • Use a list comprehension to create a new list by reversing each word from a list.
  • Use the join() function to convert the new list into a string
  • Display the resultant string

Exercise 2: Read text file into a variable and replace all newlines with space

Given : Assume you have a following text file (sample.txt).

Expected Output :

  • First, read a text file.
  • Next, use string replace() function to replace all newlines ( \n ) with space ( ' ' ).

Steps to solve this question : -

  • First, open the file in a read mode
  • Next, read all content from a file using the read() function and assign it to a variable.
  • Display final string

Exercise 3: Remove items from a list while iterating

Description :

In this question, You need to remove items from a list while iterating but without creating a different copy of a list.

Remove numbers greater than 50

Expected Output : -

  • Get the list's size
  • Iterate list using while loop
  • Check if the number is greater than 50
  • If yes, delete the item using a del keyword
  • Reduce the list size

Solution 1: Using while loop

Solution 2: Using for loop and range()

Exercise 4: Reverse Dictionary mapping

Exercise 5: display all duplicate items from a list.

  • Use the counter() method of the collection module.
  • Create a dictionary that will maintain the count of each item of a list. Next, Fetch all keys whose value is greater than 2

Solution 1 : - Using collections.Counter()

Solution 2 : -

Exercise 6: Filter dictionary to contain keys present in the given list

Exercise 7: print the following number pattern.

Refer to Print patterns in Python to solve this question.

  • Use two for loops
  • The outer loop is reverse for loop from 5 to 0
  • Increment value of x by 1 in each iteration of an outer loop
  • The inner loop will iterate from 0 to the value of i of the outer loop
  • Print value of x in each iteration of an inner loop
  • Print newline at the end of each outer loop

Exercise 8: Create an inner function

Question description : -

  • Create an outer function that will accept two strings, x and y . ( x= 'Emma' and y = 'Kelly' .
  • Create an inner function inside an outer function that will concatenate x and y.
  • At last, an outer function will join the word 'developer' to it.

Exercise 9: Modify the element of a nested list inside the following list

Change the element 35 to 3500

Exercise 10: Access the nested key increment from the following dictionary

Under Exercises: -

Python Object-Oriented Programming (OOP) Exercise: Classes and Objects Exercises

Updated on:  December 8, 2021 | 52 Comments

Python Date and Time Exercise with Solutions

Updated on:  December 8, 2021 | 10 Comments

Python Dictionary Exercise with Solutions

Updated on:  May 6, 2023 | 56 Comments

Python Tuple Exercise with Solutions

Updated on:  December 8, 2021 | 96 Comments

Python Set Exercise with Solutions

Updated on:  October 20, 2022 | 27 Comments

Python if else, for loop, and range() Exercises with Solutions

Updated on:  July 6, 2024 | 296 Comments

Updated on:  August 2, 2022 | 155 Comments

Updated on:  September 6, 2021 | 109 Comments

Python List Exercise with Solutions

Updated on:  December 8, 2021 | 200 Comments

Updated on:  December 8, 2021 | 7 Comments

Python Data Structure Exercise for Beginners

Updated on:  December 8, 2021 | 116 Comments

Python String Exercise with Solutions

Updated on:  October 6, 2021 | 221 Comments

Updated on:  March 9, 2021 | 23 Comments

Updated on:  March 9, 2021 | 51 Comments

Updated on:  July 20, 2021 | 29 Comments

Python Basic Exercise for Beginners

Updated on:  August 31, 2023 | 497 Comments

Useful Python Tips and Tricks Every Programmer Should Know

Updated on:  May 17, 2021 | 23 Comments

Python random Data generation Exercise

Updated on:  December 8, 2021 | 13 Comments

Python Database Programming Exercise

Updated on:  March 9, 2021 | 17 Comments

  • Online Python Code Editor

Updated on:  June 1, 2022 |

About PYnative

PYnative.com is for Python lovers. Here, You can get Tutorials, Exercises, and Quizzes to practice and improve your Python skills .

Explore Python

  • Learn Python
  • Python Basics
  • Python Databases
  • Python Exercises
  • Python Quizzes
  • Python Tricks

To get New Python Tutorials, Exercises, and Quizzes

Legal Stuff

We use cookies to improve your experience. While using PYnative, you agree to have read and accepted our Terms Of Use , Cookie Policy , and Privacy Policy .

Copyright © 2018–2024 pynative.com

100-Python-Projects

100 python projects 🐍.

GitHub last commit

100 Python Projects by natnew Beginner, Intermediate and advanced projects Part of the 100 Days Of Code Challenge! 🙂

If you want to learn about Python : https://docs.python.org/3/ If you want to learn about Github : https://docs.github.com/en I welcome any suggestions! ⭐

Created: October 2021 Completed: January 2022 Updated: January 2022

Welcome to the “100 Python Projects” repository! Here, we invite you to embark on an incredible journey filled with creativity, problem-solving, and the limitless possibilities of Python programming. Whether you’re a beginner or an experienced developer, this repository is designed to provide you with a diverse collection of Python projects to challenge and inspire you.

Before getting started:

📑 ebooks, guides and cheat sheets, ebook: the creative side of ai: mastering the art of prompt engineering, mastering prompt engineering: a free ebook, a - z machine learning guide, ml cheatsheet, 👀 announcements.

📢 Join the AI Adventure - 100 Days of Artificial Intelligence! 🚀 100 Days of Artificial Intelligence Project: Join us on a thrilling journey through the realms of AI as we unravel its mysteries one day at a time. Explore machine learning, neural networks, and natural language processing in this 100-day adventure, designed to enhance your understanding of artificial intelligence.

📢 Unleash the Power of Language - Introducing Awesome Prompt Engineering! 💡 Introducing Awesome Prompt Engineering Project: Dive into the fascinating world of prompt engineering, where language models are guided to generate specific outputs. Learn how to fine-tune models, craft effective prompts, and unlock the true potential of AI text generation. Discover the power of prompt engineering and harness it to create compelling and dynamic outputs.

Number Project Resources Code Tutorial
1 Internet connection, Python, IDE
2 Internet connection, Python, IDE
3 Internet connection, Python, IDE
4 Internet connection, Python, IDE
5 Internet connection, Python, IDE
6 Internet connection, Python, IDE
7 Internet connection, Python, IDE
8 Internet connection, Python, IDE
9 Internet connection, Python, IDE
10 Internet connection, Python, IDE
11 Internet connection, Python, IDE
12 Internet connection, Python, IDE
13 Internet connection, Python, IDE
14 Internet connection, Python, IDE
15 Internet connection, Python, IDE
16 Internet connection, Python, IDE
17 Internet connection, Python, IDE
18 Internet connection, Python, IDE
19 Internet connection, Python, IDE
20 Internet connection, Python, IDE
21 Internet connection, Python, IDE
22 Internet connection, Python, IDE
23 Internet connection, Python, IDE
24 Internet connection, Python, IDE
25 Internet connection, Python, IDE
26 Internet connection, Python, IDE
27 Internet connection, Python, IDE
28 Internet connection, Python, IDE
29 Internet connection, Python, IDE
30 Internet connection, Python, IDE
31 Internet connection, Python, IDE
32 Internet connection, Python, IDE
33 Internet connection, Python, IDE
34 Internet connection, Python, IDE
35 Internet connection, Python, IDE
36 Internet connection, Python, IDE
37 Internet connection, Python, IDE
38 Internet connection, Python, IDE
39 Internet connection, Python, IDE
40 Internet connection, Python, IDE
41 Internet connection, Python, IDE
42 Internet connection, Python, IDE
43 Internet connection, Python, IDE
44 Internet connection, Python, IDE
45 Internet connection, Python, IDE
46 Internet connection, Python, IDE
47 Internet connection, Python, IDE
48 Internet connection, Python, IDE
49 Internet connection, Python, IDE
50 Internet connection, Python, IDE
51 Internet connection, Python, IDE
52 Internet connection, Python, IDE
53 Internet connection, Python, IDE
54 Internet connection, Python, IDE
55 Internet connection, Python, IDE
56 Internet connection, Python, IDE
57 Internet connection, Python, IDE
58 Internet connection, Python, IDE
59 Internet connection, Python, IDE
60 Internet connection, Python, IDE
61 Internet connection, Python, IDE
62 Internet connection, Python, IDE
63 Internet connection, Python, IDE
64 Internet connection, Python, IDE
65 Internet connection, Python, IDE
66 Internet connection, Python, IDE
67 Internet connection, Python, IDE
68 Internet connection, Python, IDE
69 Internet connection, Python, IDE
70 Internet connection, Python, IDE
71 Internet connection, Python, IDE
72 Internet connection, Python, IDE
73 Internet connection, Python, IDE
74 Internet connection, Python, IDE
75 Internet connection, Python, IDE
76 Internet connection, Python, IDE
77 Internet connection, Python, IDE
78 Internet connection, Python, IDE
79 Internet connection, Python, IDE
80 Internet connection, Python, IDE
81 Internet connection, Python, IDE
82 Internet connection, Python, IDE
83 Internet connection, Python, IDE
84 Internet connection, Python, IDE
85 Internet connection, Python, IDE
86 Internet connection, Python, IDE
87 Internet connection, Python, IDE
88 Internet connection, Python, IDE
89 Internet connection, Python, IDE
90 Internet connection, Python, IDE
91 Internet connection, Python, IDE
92 Internet connection, Python, IDE
93 Internet connection, Python, IDE
94 Internet connection, Python, IDE
95 Internet connection, Python, IDE
96 Internet connection, Python, IDE
97 Internet connection, Python, IDE
98 Internet connection, Python, IDE
99 Internet connection, Python, IDE
100 Internet connection, Python, IDE

This project was created by natnew and contains Python projects from a beginners to advanced level. </details> ## Here are a few libraries that were used on these projects 📚 - [Pandas](https://pandas.pydata.org/docs/) - [Matplotlib](https://matplotlib.org/stable/index.html) - [Numpy](https://numpy.org/doc/) - [Seaborn](https://seaborn.pydata.org/) - [Statsmodels](https://www.statsmodels.org/stable/index.html) - [Scipy](https://docs.scipy.org/doc//scipy/index.html) - [Scikit-Learn](https://scikit-learn.org/stable/index.html) - [Tensorflow](https://www.tensorflow.org/) ## Latest Articles ✍️ - [Articles](https://medium.com/@natashanewbold) ## SKILLS - Python - Django - Docker - SQL - AWS - kubernetes - Machine Learning - numpy - pandas - sklearn - Azure - Google Cloud Platform - R - Natural Language Processing ## Support - Support this project. Starring⭐️ the GitHub repos is one. - Support this work on [Patreon](patreon.com/Natasha50) ## CONTACT [Portfolio](https://github.com/natnew/NATASHA-/blob/main/README.md) [Linkedin](https://www.linkedin.com/in/natasha-newbold/) [CV](https://www.linkedin.com/in/natasha-newbold/) [![HitCount](http://hits.dwyl.com/natnew/natnew/100-Python-Projects.md.svg)](http://hits.dwyl.com/natnew/natnew/100-Python-Projects/edit/main/README.md) ## License See the [LICENSE](LICENSE.md) file for license rights and limitations (MIT).

{{ activeMenu.name }}

  • Python Courses
  • JavaScript Courses
  • Artificial Intelligence Courses
  • Data Science Courses
  • React Courses
  • Ethical Hacking Courses
  • View All Courses

Fresh Articles

TripleTen Data Science Bootcamp: Insider Review

  • Python Projects
  • JavaScript Projects
  • Java Projects
  • HTML Projects
  • C++ Projects
  • PHP Projects
  • View All Projects

How to Build an Age Calculator in Python

  • Python Certifications
  • JavaScript Certifications
  • Linux Certifications
  • Data Science Certifications
  • Data Analytics Certifications
  • Cybersecurity Certifications
  • View All Certifications

DataCamp’s Certifications To Get You Job-Ready: Insider Review

  • IDEs & Editors
  • Web Development
  • Frameworks & Libraries
  • View All Programming
  • View All Development

The Best Computer for Android Development: Minimum and Recommended Specs

  • App Development
  • Game Development
  • Courses, Books, & Certifications
  • Data Science
  • Data Analytics
  • Artificial Intelligence (AI)
  • Machine Learning (ML)
  • View All Data, Analysis, & AI

Insider Review of DataCamp’s AI-Powered DataLab Tool

  • Networking & Security
  • Cloud, DevOps, & Systems
  • Recommendations
  • Crypto, Web3, & Blockchain
  • User-Submitted Tutorials
  • View All Blog Content

Last Mile Education Fund helps students cover costs while learning cybersecurity

  • Python Online Compiler
  • JavaScript Online Compiler
  • HTML & CSS Online Compiler
  • Certifications
  • Programming
  • Development
  • Data, Analysis, & AI
  • Online Python Compiler
  • Online JavaScript Compiler
  • Online HTML Compiler

Don't have an account? Sign up

Forgot your password?

Already have an account? Login

Have you read our submission guidelines?

Go back to Sign In

python assignment project

30 Best Python Projects Beginner to Pro With Code [2024]

If I could go back in time to help my younger self learn Python, I'd tell them to build more Python projects!

That's exactly why I wrote this article: to share 30 Python projects to help programmers like you.

Whether you’re looking to start a career in Python development or enhance your portfolio, these Python projects are perfect for leveling up your Python skills.

I’ve personally designed each of these Python projects, including a range of step-by-step tutorials so you can follow along with me to get hands-on and code some cool stuff.

You can think of these tutorial projects as taking a free Python course while growing your Python portfolio!

I'm also regularly adding new Python projects with step-by-step tutorials, so make sure you bookmark this page and check back for the latest Python projects to grow your skills.

Without further ado, let’s dive in and start building with Python!

Plus, if you're looking for some extra help, I've also released my own course, Python with Dr. Johns , where I take an academic approach to teaching while also building portfolio-worthy Python projects.

  • Best Python Projects for Beginners in 2024

1. Python Hangman Game with GUI

What is this Python project?

In this Python project, you'll build a Hangman game, an engaging and fun game that challenges users to guess words letter by letter.

I've also designed this project to be a step-by-step tutorial so you can follow along with me to build something very cool and fun!

This project also goes beyond merely creating a functional application; it serves as an excellent example of utilizing Python's simplicity and the Tkinter library to create interactive and visually appealing desktop applications.

It's also a perfect addition to your portfolio, particularly if you're looking to demonstrate your proficiency in Python development, as it showcases fundamental programming concepts in a context that's interactive while also showing your understanding of user interface design and event-driven programming.

So get ready and fire up your favorite Python IDE , and let's get building!

Python Skills Covered:

  • Game Logic: Craft the core logic for processing guesses, managing game states, and determining win or loss conditions, offering a deep dive into conditional statements and data structures.
  • Dynamic UI Updates: Utilize Tkinter to dynamically update the game interface, reflecting the progress of the game and user interactions in real-time, thus enriching the user experience.
  • Event Handling: Employ event listeners to capture user inputs such as letter guesses and actions to restart or exit the game, showcasing how to interact with GUI elements in Python.
  • User Interface Design: Use Tkinter to design a clean, intuitive interface for the Hangman game, demonstrating skills in creating visually appealing and user-friendly desktop applications.
  • Tkinter and Python Basics: Harness the power of Python and its standard GUI toolkit, Tkinter, to implement and manage the game's interface.
  • Best Practices in Python: Write clean, efficient, and well-documented Python code, adhering to best practices for code structure, readability, and maintainability.

Build This Python Project Here

2. Mad Libs Generator 

This is one of the most fun beginner Python projects, not to mention it lets you practice how to use strings, variables, and concatenation, which are essential skills for all Python applications at all skill levels.

The Mad Libs Generator gathers and manipulates user input data as an adjective, a pronoun, and a verb. The program takes this data and arranges it to build a story.

Source Code:

3. Number Guessing 

This beginner Python project is a fun game that generates a random number (in a certain range) that the user must guess after receiving hints. For each wrong guess the user makes, they receive extra hints but at the cost of worsening their final score.

This program is a great way to experiment with the Python standard library, as it uses the Python random module to generate random numbers. You can also get some hands-on practice with conditional statements, print formatting, user-defined functions, and various Python operators .

4. Rock Paper Scissors

This Rock Paper Scissors program simulates the universally popular game with functions and conditional statements. So, what better way to get these critical concepts under your belt? You'll also be using the Python list to store a collection of valid responses, which you can then use to create an elegant and Pythonic conditional statement.

As one of many Python coding projects that imports additional libraries, this program uses the standard library’s random , os , and re modules.

Take a look at the code below, and you’ll see that this Python project idea asks the user to make the first move by passing in a character to represent rock, paper, or scissors. After evaluating the input string, the conditional logic checks for a winner.

Updated! I've recently updated this rock paper scissors python project to include a score-keeping system. It tracks the user's score and the computer's score. It also displays that score between rounds and at the end of the game.

There's one more update here. I wanted to accept a single letter "Y" for those who want to keep playing. Before, you had to type of out "yes". I've left off the ability to accept "N" for "no". That's an easy challenge for those who want to improve my rock paper scissors python project.

5. Dice Roll Generator

As one of the most relatable Python projects for beginners with code, this program simulates rolling one or two dice. It’s also a great way to solidify your understanding of user-defined functions, loops, and conditional statements. These are fundamental skills for Python beginners and are likely to be some of the first things you’d learn, whether that’s from an online course or a Python book .

As one of our easy Python projects, it’s a fairly simple program that uses the Python random module to replicate the random nature of rolling dice. You’ll also notice that we use the os module to clear the screen after you’ve rolled the dice.

Note that you can change the maximum dice value to any number, allowing you to simulate polyhedral dice often used in many board and roleplaying games.

6. Password Strength Checker

If you fancy learning how to create an app , this Python project could be a great addition, as it lets you check whether your password is strong enough.

It does this by checking the number of letters, numbers, special characters, and whitespace characters within a given password and generating a score based on these results. So, it’s another great way to learn about conditional statements, functions, and string formatting.

We also use the string and getpass modules from the Python standard library. This allows us to access the full range of string characters to compare with our password’s character composition, while the .getpass() function lets us hide our password when we enter it.

7. Number to Words

This Python project idea converts an integer number provided via user input to its equivalent words. This program is set up to support numbers with a maximum of 12 digits, but feel free to modify the program to handle larger numbers (hint: requires conditional statements and loops).

As an easy-to-understand example of basic Python projects, this simple but effective program can expand your skills with loops, user input, and conditional statements, not to mention Python tuples and lists.

You’ll also be able to experiment with some mathematical operations that may be new to you like the modulo (%) operator to return the remainder from integer division.

If any of these techniques are new to you, you might consider installing an AI coding assistant in your Python IDE to help offer help with any code blocks you find challenging to understand.

8. Tic-Tac-Toe Game

Tic-Tac-Toe is a classic two-player game that involves a nine-square grid. Each player alternately marks their space with an O or an X, and whichever player manages to mark three Os or Xs diagonally, horizontally, or vertically wins. Each player must also block their opponent while attempting to make their chain.

This is a really fun Python project that’s unique for beginners, as it uses object-oriented programming. 

This is one of the most essential Python concepts to learn, and in this project, you will create a new class called TicTacToe. We’ll then use this to represent the game's features via the class attributes and methods.

Carefully study these methods to see how we can use object-oriented programming to neatly package the various behaviors needed to simulate this game.

Some new aspects of this Python project idea for beginners include nested loops to check the grid's columns, rows, and diagonals for a winning state, along with the Python set data type, which is used to contain unique values. This program also uses the Python random module to select a random player to start the game, but this is more familiar to you now.

9. Calculator

Another of our easy Python projects, this program creates a basic calculator application with addition, subtraction, multiplication, and division functions.

This is one of the Python practice projects that are great for learning how to use loops, functions, conditional statements, user input, and string formatting. We’ve also used the Python os module to clear the screen after the user completes their calculation actions.

Once you have the concepts under your belt with this project, consider ways to extend the features to include exponentiation or other more complicated calculations.

If you’re already using an AI coding assistant like GitHub Copilot or Amazon CodeWhisperer , you could also consider experimenting with this to add new features. Try to do it yourself first though!

Sample Code:

10. Countdown Clock and Timer

This Python project idea is fun! Here, we’ve created a countdown timer that asks the user for a number of seconds via user input, and it then counts down, second by second, until it displays a message.

We’ve used the Python time module’s .sleep() function to pause for 1-second intervals. We combine this with some nifty string formatting to produce the countdown display.

  • Intermediate Python Projects With Source Code

11. Binary Search Algorithm

It’s a rite of passage for all aspiring coders to tackle Binary Search in one of their Python programming projects at some point! I know when I was starting out, some of my most common Python mistakes involved classic algorithms like this.

This Python project for binary search takes in a sorted list (array), then continually compares a search value with the middle of the array.

Depending on whether the search value is less than or greater than the middle value, the list is split (divide and conquer strategy) to reduce the search space, which hones in on the given search value. This continual division results in logarithmic time complexity.

If you look at the code below, you’ll see that we’ve implemented two solutions: conditional loops and recursion. Both approaches are elegant, so feel free to experiment with each.

If you’re new to recursion, this is a great introduction as it demonstrates how we ‘reduce’ the size of the problem with each recursive call, namely by splitting the list to one side of the current middle element.

We’ve also defined the recursive base case as the point when the middle element equals the search element. In this case, the recursion will stop and return the True value up through the call stack.

If this all sounds alien to you, consider using something like GitHub Copilot to make more sense of this classic algorithm.

12. Merge Sort Algorithm

Merge Sort is another popular coding challenge faced by aspiring coders when looking for things to do in Python.

This divide-and-conquer strategy uses division to separate a list of numbers into equal parts, and these are then recursively sorted before being recombined to generate a sorted list.

If you’ve just completed the Binary Search example, you might notice some similarities with division and reducing a problem’s size. You’d be right, which means you’ve likely realized we need to use recursion.

This Python implementation of Merge Sort uses recursion to handle the divide and conquer process. The continual reduction of the problem size allows the problem to be solved when the recursive base case is reached, namely when the problem size is one element or less.

In essence, this Python program continues to recursively divide the list until it reaches the base case. At this point it begins sorting the smaller parts of the problem, resulting in smaller sorted arrays that are recombined to eventually generate a fully sorted array. If you’re familiar with Big O notation, you’ll be curious to know that Merge Sort has a Big O of (n logn).

13. Password Generator

This is an interesting Python project that uses the secrets and string modules to generate a strong and secure password, much like you can with popular password managers.

The string module obtains all possible letters, digits, and special characters, while the secrets module allows us to obtain cryptographically secure passwords.

The code for this project is relatively simple as it uses a loop to continually generate passwords until it contains at least one special character and two digits. You can, of course, modify this to fit your own super-strong password rules!

14. Currency Converter

This is one of several Python project ideas that require us to install one of the most popular Python libraries , which in this case, is the requests module. This is not included with the Python standard library, so use the pip command shown in the source code to install it on your system.

With the requests module, we can make HTTP requests to the Fixer API, allowing us to convert one currency to another. You’ll likely notice that we’re using a 3rd party API, so you’ll need to sign up to get a free API key . You can then enter your API key into the field shown in the source code, and you’ll be ready to go!

This project allows you to gain some more practice with loops and user input, but it expands on this with HTTP requests to retrieve API data in JSON format.

If you’re unfamiliar with JSON, it’s very similar to a Python dictionary, meaning we can access key-value pairs to fetch the data we’re after. In this case, we are looking for the currency conversion result from the API call.

Look at the docs on the Fixer API site for more details on the different data you can retrieve.

15. Automatic Birthday Mail Sending

This Python project uses the standard smtplib , EmailMessage, and datetime modules, in addition to pandas and openpyxl (these need to be pip installed, as shown below) to send automated birthday emails.

This program reads from an Excel sheet that contains all of your friends’ details (see Excel sheet format in source code below). It then sends them an email if today is their big day before making a note in your spreadsheet to say they’ve received their email.

We’ve used the smtplib and EmailMessage modules to create an SSL connection to our email account and message. We’ve then used a pandas dataframe to store spreadsheet-style data within the Python program (an essential skill for data scientists). Finally, we used date formatting with the datetime module’s .strftime() function.

So, lots of new skills to get to grips with!

Important note: since May 2022, Google has tightened its restrictions on ‘less secure apps’ accessing Gmail. You’ll need to follow some extra steps to use this code with your Gmail account. But don’t worry, they’re easy to do, and we’ve listed them for you.

  • Go to the ‘manage account’ page for your google account
  • Click on Security
  • Enable 2FA (use whichever method you prefer)
  • Click on ‘App Passwords’
  • Click on ‘Select App’ and select ‘Mail’
  • Click on ‘Select Device’ & select ‘Other (custom name)’, enter ‘Python Birthday App’
  • Click on ‘Generate’ then save this password

You can now use this app password in the code below to access your Gmail account with no trouble!

This Python project creates a new class to implement a Queue . This is a common data structure in computer science when you need to handle First-In-First-Out (FIFO) scenarios, such as message queues, CPU tasks, etc.

The code is straightforward and offers some more practice with object-oriented programming. Test out the queue to get your head around how it works, and then you’ll be ready to use this data structure in your other projects.

17. Pascal’s Triangle

This Python project prints out Pascal’s Triangle using conditional statements and loops. It also uses the standard library’s math module and factorial function to evaluate the ‘number of combinations’ equation used to generate the values in the triangle.

Experiment with the seed number for the triangle to examine how the ‘combinations’ equation is used to generate successive values in the triangle. 

18. Blackjack

As one of the coolest Python projects, this will appeal to anyone who enjoys card games, as we will emulate Blackjack. This is a super popular card game with relatively simple rules: the most important being you need 21 to win, or you need a higher score than the dealer without going bust!

This is the largest project on the list so far. It combines most of the skills we’ve already covered in previous projects, including creating classes, loops, conditional statements, importing modules, accepting user input, and string formatting.

Take your time to work through the different sections of this code, and relate it to the earlier projects to see how the different techniques work together. There’s nothing you haven’t seen before; it’s just been packaged slightly differently and combined to create a fully functional game emulator.

And we should say, try not to spend all day playing with it! But we totally understand if you do!

19. Reddit Bot

This Python project creates an automated Reddit bot with some new modules, namely praw and enchant (see the pip install commands).

This is a fairly simple concept as the program checks every comment in a selected subreddit and then replies to any comments that contain a predefined ‘trigger phrase’. To do this, we use the praw module to interact with Reddit, and enchant to generate similar words to the comment, allowing us to make an appropriate reply.

This idea is really useful if you’re looking for Python projects to learn how to answer questions in your own subreddit. You’d just need to expand this code to include automated responses for predefined questions (you’ve probably already noticed this being used by others on Reddit!). 

Important note: You’ll need to check out these instructions to get hold of a client_id, client_secret, username, password, and user_agent. You’ll need this information to make comments to Reddit via the API interface.

20. Fibonacci Generator

The Fibonacci numbers may be some of the most important numbers in our lives as they appear so often in nature.

The Python code below generates the Fibonacci numbers up to a certain length using recursion (yes, more recursion!). To stop the computation times from getting out of hand, we’ve implemented memoization to cache values as we calculate them.

You’ll notice that for this recursive algorithm, the base case is set to check whether the given Fibonacci sequence value is already stored in the cache. If so, it returns this (which is a constant time complexity operation), which saves a tremendous amount of computation time.

  • Advanced Python Project Ideas

21. Chatbot

This Python project uses the chatterbot module (see pip install instructions below) to train an automated chatbot to answer any question you ask! I know; we’re now using AI!

You’ll see that the program is one of the relatively small Python projects in this list, but feel free to explore the ChatterBot documentation along with the broader field of AI chatbots if you’d like to learn more or expand the code’s features.

If this has whet your appetite for building AI bots, check out our 24-Hour Python Chatbot course to learn how to build an AI-powered chatbot with the same tools that power OpenAI’s ChatGPT.

And if you're hungry for even more AI goodness, check out OpenAI,'s latest feature that lets you  build your own GPT .

Important note: ChatterBot is no longer being actively maintained. This means you need to make a small change to the tagging.py file located in the ‘Lib/site-packages/chatterbot’ directory of your Python installation folder.

Don’t worry; it’s straightforward to do, and we’ve included the exact source code you need to use, as shown below.

Modify tagging.py:

Find the first code snippet, which is part of the __init__ method for the PosLemmaTagger class. Replace this with the if/else statement.

Note: this example is for the English library we used in our example, but feel free to switch this out to another language if you’d prefer.

22. Text to Speech

This Python project uses a range of new libraries to convert an existing article into a playable mp3 file. You’ll need to install nltk (natural language toolkit), newspaper3k, and gtts (see pip install instructions).

You’ll see that the program is simple, as we simply pass in a URL for an article to convert, then let the function we’ve defined handle the text-to-speech conversion with our newly installed modules.

So, consider trying this out the next time you fancy turning an article into a playable podcast as it’s definitely one of the cool Python codes to copy! 

23. Library Management System

As one of the more advanced Python projects, this program uses object-oriented programming to simulate a library management system.

In this example, we create a Library and Student class, which we can use to create our library system and its users. We’ve then implemented a simple user interface that asks users to select from a range of standard library actions, like borrowing or returning books. 

This is a simple yet powerful example of how you can build out real-world systems via Python and object-oriented programming. Feel free to expand the classes to include other useful features, like unique book IDs, multiple copies of the same book, return dates, fees for returning books late, or any other features you think a library should have!

24. Pong Arcade Game

This is a really fun and interesting project, as we’ve used the Python turtle module to emulate the classic arcade game Pong!

We’ve used various methods from the turtle module to create our game components and detect ball collisions with the player paddles. We’ve also defined a range of keybindings to set the user controls for the left and right player paddles. Feel free to experiment with the game’s settings to better understand how each setting works and affects the overall game.

Outside of these newly introduced turtle graphics functions, we’ve used string formatting to output the current scoreboard and user-defined functions to keep our code tidy. These are concepts you should be familiar with at this stage.

25. Speed Typing Test

This is an interesting Python project that tests how quickly you can accurately type out a sentence.

This program requires us to create a graphical user interface (GUI) via the tkinter module. If you’re new to GUIs, this example is a nice introduction as we use a range of simple labels, buttons, and entry fields to create a window. We’ve also used the Python timeit module to handle the timing aspect of our typing test, and the random module to randomly select a test phrase.

We’ve only added two test phrases to this example, but feel free to experiment with more or even integrate a 3rd party dictionary for a wider array of examples.

26. Text Editor

Building on our last tkinter example, this fun Python project creates a GUI to simulate our very own text editor. This example also uses standard GUI components, including labels, buttons, and entry fields.

However, we’ve also added the ability to open and save files like a real text editor. If you’re new to file handling, this Python project is a great way to understand how to read-in and save files.

Experiment with the code below to solidify your understanding, and see if you can expand on this code to create other features you’re used to using with a text editor, like a ‘find word’ function.

27. Sudoku Solver

This Python project uses the pygame library (see pip install instructions) to implement a GUI for automatically solving sudoku puzzles. We use several user-defined functions to create the GUI, as shown below.

To solve a sudoku puzzle, this program uses a backtracking algorithm that incrementally checks for solutions, either adopting or abandoning the current solution if it’s not viable.

This step of abandoning a solution is the defining feature of a backtracking approach, as the program steps back to try a new solution until it finds a valid one. This process is incrementally carried out until the entire grid has been correctly filled.

Feel free to experiment with different sudoku problems, and even think about expanding the size of the problem grid (you’ll need a new base image if you do this).

28. Site Connectivity Checker

This Python project uses the urllib and tkinter modules to test website connectivity.

We’ve used the tkinter module to create a GUI allowing users to enter a web address. Much like our previous examples, this includes labels, buttons, and entry fields.

After we’ve collected the user’s web address, we pass this to our user-defined function to return an HTTP status code for the current website via the urllib module’s .getcode() function.

For this example, we simply determine whether the HTTP code is 200. If it is, we know the site is working; otherwise, we inform the user that it is unavailable.

You could expand this code to consider a more granular approach to handling the various HTTP response codes, so feel free to add this!

29. Language Detector

This Python project uses the langdetect module (see pip install instructions) to help us identify the language that has been entered. This can be really useful if you’re unsure which language you’re dealing with. 

This is another example where we’ve used tkinter to create a simple GUI involving labels, buttons, and an entry field. We can then collect text from the entry field and process this with the langdetect to determine which language was entered. Finally, we print this result to the GUI to let the user know the result.

Note that the results returned by langdetect are abbreviated language codes. For example, if we enter English text, we will see ‘en’ as the return value.

30. Netflix Recommendation System

To cap it all off, we’ve saved a particularly exciting Python project for last! This is a Netflix recommendation system, ideal for aspiring data scientists. In fact, if you’re considering a machine learning course , this is a great project to reinforce your new skills.

To create this project, you’ll need to import a range of modules, including tkinter, re, nltk, pandas, and numpy (see pip install instructions for new modules). You’ll also need to download a Kaggle dataset containing Netflix movies and TV shows. 

We’ll use tkinter to create our GUI, which will use labels, buttons, and entry fields. The user will then be able to enter a TV show or movie they enjoyed on Netflix to return recommendations based on their taste. 

The recommendation engine uses cast, director, ratings, country, and genres as machine learning (ML) ‘features’. The code then uses the ‘cosine similarity’ approach to find similar results based on user input. This extensively uses pandas and numpy to clean the data and prepare it for processing.

There is a lot to unpack in this example, as it uses lots of Python concepts for data science .

The best approach is to slowly work through the code and then carry out further research on Machine Learning (ML), ‘features’, and ‘cosine similarity’. 

You’ll then be able to understand how to use a dataset to derive recommendations based on similarities. If you’re an aspiring data scientist, this is a terrific project to get your feet wet!

  Bonus Project: Age Calculator

I recently made a new project based on a reader request. The novice programmer wanted to make an age calculator in Python, but he was having trouble. That's why I wrote this article.

Like my projects above, this one contains source code and an explanation about why I used the code I used.

How to Build an Age Calculator in Python

  • Where To Start With Python

Today, we’re experiencing an ever-growing adoption of Artificial Intelligence (AI), Machine Learning (ML), and data science across the vast majority of business sectors. One of the main things these fields have in common is that they use the Python programming language in one way or another.

When it comes to learning Python in 2024, you have so many choices. Plus, if you'd prefer an in-depth and interactive learning experience, we’d also recommend our new Python course . 

  • What Should I Build Using Python?

This is a great question, especially if you’re brand new to coding in Python.

Well, first things first, you should know that there are so many Python applications in various disciplines, so you have lots of options.

Of course, Python has developed a solid reputation for data science, data analysis, machine learning, and AI, but it doesn’t end there.

It’s also really good when it comes to web development, thanks to popular web application frameworks like Django and Flask .

Equally, it’s also ideal for automating repetitive tasks, hence its origin as a scripting language.

To put it simply, you can build a lot with Python, but if you’re looking for inspiration, you’re in the right place!

That's why I put together 30 Python projects for you to get stuck into, ranging from beginner to advanced.

  • Wrapping Up

And there we have it! If you've taken the time to build these 30 Python projects, you should be feeling much more competent and confident with Python.

You'll also have a burgeoning Python portfolio that's packed full of interesting and practical Python projects, each demonstrating your dedication and abilities.

I also hope you enjoyed following along with my step-by-step tutorial in the first Python project!

My motivation with these Python tutorials is to guide you through the nuances of Python development while also giving you hands-on experience that you'd usually only get when taking a Python course.

Here at hackr.io, we're huge fans of project-based learning, so I hope these Python projects have bolstered your confidence and sparked a deeper interest in web development or any other form of Python development.

Remember, the journey doesn't end here!

With new projects and step-by-step tutorials regularly added to this page, be sure to check back often for new opportunities to refine your Python skills and expand your portfolio.

Happy coding!

Enjoyed tackling these Python projects and are ready to dive deeper into Python? Check out:

Our Python Masterclass - Python with Dr. Johns

  • Frequently Asked Questions

1. Is Python Suitable for Large Projects?

Although there is the argument that Python is slower than other popular languages like C and C++, Python is still widely used by many top tech companies because it is super versatile, easily maintainable, and offers a ton of libraries and support from the community.

2. What Should My First Python Project Be?

Check out any of the Python beginner projects we’ve covered above, including Mad Libs, Rock Paper Scissors, Hangman, or Tic-Tac-Toe!

People are also reading:

  • Python Interview Questions
  • Python Web Scraping Guide
  • Python Frameworks
  • Python While Loop
  • Python Is & Equality Operators
  • Python Conditional Statements
  • Python RegEx Cheat Sheet
  • Python Interpreters

1. Bureau of Labor Statistics, U.S. Department of Labor. Occupational Outlook Handbook, Software Developers [Internet]. [updated 2021 Sep 8; cited 2024 Jan 15]. Available from: https://www.bls.gov/ooh/computer-and-information-technology/software-developers.htm

2. apilayer. FIXER API - Pricing [Internet]. apilayer; [date unknown; cited 2024 Jan 15]. Available from: https://apilayer.com/marketplace/fixer-api#pricing

3. [no author]. OAuth2 Quick Start Example [Internet]. GitHub; [updated 2016 Apr 26; cited 2024 Jan 15]. Available from: https://github.com/reddit-archive/reddit/wiki/OAuth2-Quick-Start-Example#first-steps

4. Makhija, S. Netflix Movies and TV Shows 2021 [dataset]. Kaggle; 2021. Available from: https://www.kaggle.com/datasets/satpreetmakhija/netflix-movies-and-tv-shows-2021?resource=download

python assignment project

Technical Editor for Hackr.io | 15+ Years in Python, Java, SQL, C++, C#, JavaScript, Ruby, PHP, .NET, MATLAB, HTML & CSS, and more... 10+ Years in Networking, Cloud, APIs, Linux | 5+ Years in Data Science | 2x PhDs in Structural & Blast Engineering

Subscribe to our Newsletter for Articles, News, & Jobs.

Disclosure: Hackr.io is supported by its audience. When you purchase through links on our site, we may earn an affiliate commission.

In this article

  • 10 Vital Python Concepts for Data Science
  • 10 Common Python Mistakes in 2024 | Are You Making Them? Python Data Science Programming Skills
  • 10 Python Concepts I Wish I Knew Earlier For Interviews [2024] Python Career Development Interview Questions

Please login to leave comments

python assignment project

all codes has so many mistakes

3 years ago

python assignment project

Robert Johns

Thanks for pointing this out. If you take a look at our latest projects, they should be all bug-free.

10 months ago

Esther Ndosi

Thank you for all these cool projects. Its great to start a year with them. On the second project I think the attempts should be appended after the guess == rand_num as it always print 1 and i think it should be the lowest attempts the user has. thank you.

7 months ago

Thanks for taking the time to build these projects and spotting that. The second project has been updated, check it out and see what you think.

Embarking on a Python journey with these hands-on projects feels like unlocking a treasure trove of coding adventures!

3 months ago

Always be in the loop.

Get news once a week, and don't worry — no spam.

{{ errors }}

{{ message }}

  • Help center
  • We ❤️ Feedback
  • Advertise / Partner
  • Write for us
  • Privacy Policy
  • Cookie Policy
  • Change Privacy Settings
  • Disclosure Policy
  • Terms and Conditions
  • Refund Policy

Disclosure: This page may contain affliate links, meaning when you click the links and make a purchase, we receive a commission.

50+ Python Projects with Source Code: Beginner to Advanced

Faraz Logo

By Faraz - June 17, 2024

Popular 50+ Python projects with source code, suitable for all skill levels. From basic to advanced, start coding today! #PythonProjects

50+ Python Projects with Source Code Beginner to Advanced.jpg

Table of Contents

Sr NoProjectAuthor
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52

Introduction to Python Projects

Python is a versatile programming language known for its simplicity and readability. It's widely used in various domains such as web development, data analysis, machine learning, automation, and more. One of the best ways to master Python is by working on projects. In this blog post, we present a comprehensive collection of over 50 Python projects complete with source code. Whether you're a beginner looking to practice your skills or an experienced programmer seeking new challenges, these projects offer something for everyone.

1. Alarm Clock

alarm clock using python

Are you looking to build your Python skills while creating something useful? Start with a simple yet practical project like an Alarm Clock. With Python, you can code an alarm clock that wakes you up with your favorite tune or a custom message.

2. Calculator

python calculator gui using tkinter

Mastering Python isn't just about complex algorithms; it's also about solving everyday problems. Build a calculator using Python to perform basic arithmetic operations. It's a great way to understand functions, user input, and mathematical operations in Python.

3. QR Code Generator

qr code generator using Python

QR codes are everywhere these days, and understanding how to generate them using Python can be a valuable skill. Create a QR code generator application that allows users to input text or a URL and generates a QR code image that they can save or share.

4. Password Generator

password generator and manager

Security is crucial, especially in the digital age. Develop a password generator application in Python that creates strong and random passwords based on user-defined criteria such as length and character types. It's a practical project that enhances your skills while promoting cybersecurity.

5. Guess the Number

guess the number with python

Embark on a classic programming challenge by creating a "Guess the Number" game in Python. Challenge the user to guess a randomly generated number within a certain range. This project will reinforce your understanding of loops, conditionals, and user interaction in Python.

6. Age Calculator

python age calculator

Explore date and time manipulation in Python by building an Age Calculator. Allow users to input their birthdate, and then calculate and display their age in years, months, and days. It's a practical application that demonstrates Python's datetime module functionalities.

7. Weather Forecast App

python weather forecast app

Combine your Python skills with web scraping to develop a Weather Forecast App. Utilize APIs or web scraping techniques to fetch real-time weather data from online sources and present it in a user-friendly interface. This project will enhance your knowledge of data retrieval and visualization in Python.

8. Photo Compressor

photo compressor using python

Optimize images with a Python-based Photo Compressor. Create an application that reduces the file size of images while preserving their quality. You can explore image processing libraries like Pillow to implement various compression techniques and improve your understanding of image manipulation in Python.

9. Vending Machine

vending machine with python

Simulate the functionality of a vending machine using Python. Design a program that allows users to select items, input payment, and receive their chosen product. This project will help you grasp concepts such as conditionals, loops, and data structures while simulating real-world scenarios.

10. Youtube Downloader

python based youtube downloader

Build a Youtube Downloader application in Python to download videos from YouTube. Utilize third-party libraries like pytube to fetch video URLs, download videos, and save them to the local filesystem. This project will introduce you to working with APIs and handling multimedia data in Python.

11. Typing Speed Test

python typing speed test

Sharpen your typing skills while practicing Python programming with a Typing Speed Test project. Develop an application that prompts users to type a passage within a specified time limit and calculates their words per minute (WPM) and accuracy. This project will enhance your understanding of string manipulation and timing functions in Python.

12. Currency Converter

python currency converter

Dive into the world of financial applications by creating a Currency Converter in Python. Utilize exchange rate APIs or manually input conversion rates to allow users to convert between different currencies. This project will deepen your understanding of data manipulation and user input handling in Python.

13. Quiz Application

quiz application using tkinter

Create an interactive Quiz Application using Python to challenge users with a variety of questions. Implement features such as multiple-choice, true/false, and fill-in-the-blank questions, along with scoring and feedback mechanisms. This project will reinforce your knowledge of data structures and user interfaces in Python.

14. Word Counter

python word counter gui

Enhance your text processing skills by building a Word Counter application in Python. Develop a program that analyzes text input and calculates the frequency of each word, along with other statistics such as total words and unique words. This project will strengthen your understanding of dictionaries, strings, and file handling in Python.

15. Bitcoin Price Tracker

bitcoin price tracker with python and bs4

Stay up-to-date with cryptocurrency trends by creating a Bitcoin Price Tracker in Python. Fetch real-time Bitcoin prices from cryptocurrency APIs and display them in a graphical or text-based interface. This project will introduce you to working with APIs and handling JSON data in Python.

16. MP3 Player

python mp3 player

Immerse yourself in the world of multimedia applications by developing an MP3 Player in Python. Utilize libraries like pygame or tkinter to create a graphical user interface (GUI) that allows users to play, pause, stop, and navigate through their music library. This project will enhance your understanding of audio playback and GUI programming in Python.

17. Generate Random Jokes

python generate random jokes

Inject some humor into your Python projects by building a Random Jokes Generator. Fetch jokes from online APIs or create a collection of jokes and randomly select and display them to the user. This project will reinforce your skills in working with APIs, strings, and randomization in Python.

18. Text Editor/Notepad

python text editor/notepad

Create a simple Text Editor or Notepad application in Python to manage and edit text files. Implement features such as opening, editing, saving, and formatting text, along with functionalities like search and replace. This project will deepen your understanding of file handling and GUI programming in Python.

19. Digital Clock

digital clock in python with tkinter

Explore graphical user interfaces (GUIs) in Python by building a Digital Clock application. Design a clock interface that displays the current time and updates in real-time. You can use libraries like tkinter or pygame to create the GUI elements and handle time-related functionalities. This project will enhance your knowledge of GUI programming and event handling in Python.

20. Flappy Bird

python flappy bird

Challenge yourself with game development by creating a Flappy Bird clone in Python. Utilize libraries like pygame to design the game mechanics, graphics, and user interface. Implement features such as bird movement, pipe generation, collision detection, and scoring. This project will deepen your understanding of game development concepts and object-oriented programming (OOP) in Python.

21. Brick Breaker Game

brick breaker game

Experience the thrill of classic arcade gaming by developing a Brick Breaker game in Python. Use libraries like pygame to create the game environment, paddle, ball, and bricks. Implement features such as ball movement, collision detection, power-ups, and scoring. This project will reinforce your understanding of game physics and event handling in Python.

22. Captcha Generator

python captcha generator

Protect websites from spam and bots by creating a Captcha Generator in Python. Design an application that generates random Captcha images with distorted text, which users must correctly identify to proceed. This project will deepen your understanding of image manipulation and randomization in Python.

23. Scientific Calculator

scientific calculator using python

Delve into advanced mathematical concepts with a Scientific Calculator project in Python. Develop a calculator application that supports functions like trigonometry, logarithms, exponents, and more. This project will challenge you to implement complex mathematical algorithms and enhance your problem-solving skills in Python.

24. PDF 2 Image Converter

python pdf 2 image converter

Unlock the potential of document processing by creating a PDF to Image Converter in Python. Utilize libraries like PyPDF2 and Pillow to extract pages from PDF files and convert them into image formats like JPEG or PNG. This project will introduce you to working with different file formats and image processing techniques in Python.

25. Hash Cracker

hash cracker using python

Explore the world of cryptography by developing a Hash Cracker application in Python. Design a program that can crack hashed passwords using techniques like dictionary attacks or brute force. This project will deepen your understanding of encryption algorithms, string manipulation, and cybersecurity concepts in Python.

26. Python Bounce Game

python_bounce_game

Immerse yourself in game development by creating a Python Bounce Game. Utilize libraries like pygame to design the game environment, ball, and paddles. Implement features such as ball movement, collision detection, and scoring. This project will deepen your understanding of game physics and event handling in Python.

27. Dino Game

google chrome dino game made with python

Explore the world of web browser games by recreating the classic Dino Game from Google Chrome's offline mode. Use libraries like pygame to design the game environment and implement features such as jumping, ducking, and avoiding obstacles. This project will challenge you to create a game with simple mechanics while honing your skills in Python.

28. PNG to JPG

png to jpg using python and tkinter

Expand your image processing skills by developing a PNG to JPG Converter in Python. Utilize libraries like Pillow to load PNG images, convert them to JPG format, and save them to the local filesystem. This project will deepen your understanding of image file formats and manipulation techniques in Python.

29. Connect Four Game

connect four game in python

Challenge yourself with board game development by creating a Connect Four game in Python. Design the game board, pieces, and rules, and implement features such as dropping pieces, checking for win conditions, and handling player turns. This project will reinforce your understanding of game logic and algorithms in Python.

30. Car Race Game

game car race in python

Experience the thrill of racing games by developing a Car Race Game in Python. Utilize libraries like pygame to design the game environment, cars, and tracks. Implement features such as car movement, collision detection, and scoring. This project will deepen your understanding of game physics and simulation in Python.

31. Digital Certificate Creation

digital certificate creation using python

Enter the realm of cybersecurity by developing a Digital Certificate Creation tool in Python. Design a program that generates digital certificates using cryptographic techniques such as public-key encryption. This project will deepen your understanding of cryptography and secure communication protocols in Python.

32. Chatbot

python_chatbot

Explore the exciting field of natural language processing (NLP) by creating a Chatbot in Python. Design an interactive conversational agent that can respond to user inputs and engage in meaningful conversations. This project will introduce you to NLP libraries like NLTK or spaCy and enhance your skills in text processing and machine learning in Python.

33. Rock Paper Scissors Game

rock paper scissors game in python

Relive the timeless fun of the Rock Paper Scissors game by creating your own version in Python. Design the game mechanics, user interface, and implement features such as player input, computer AI, and scoring. This project will reinforce your understanding of conditional statements and randomization in Python.

34. Music Player

python_gui_music_player

Immerse yourself in multimedia applications by developing a Music Player in Python. Utilize libraries like pygame or tkinter to create a graphical user interface (GUI) that allows users to play, pause, stop, and navigate through their music library. This project will enhance your understanding of audio playback and GUI programming in Python.

35. Restaurant Management System

restaurant management system in python

Explore the world of software solutions for businesses by developing a Restaurant Management System in Python. Design a program that allows restaurant staff to manage orders, inventory, and customer information efficiently. This project will deepen your understanding of data management and user interface design in Python.

36. Python Dictionary

python dictionary

Dive into data structures by creating a Python Dictionary application. Design a program that allows users to add, remove, and search for entries in a dictionary. Implement features such as key-value pair management and dictionary manipulation. This project will reinforce your understanding of dictionaries and data organization in Python.

37. Test Internet Speed

python test internet speed

Monitor your internet connection with a Test Internet Speed tool in Python. Design a program that measures the download and upload speeds of your internet connection and displays the results. This project will introduce you to network programming concepts and enhance your skills in working with external APIs in Python.

38. Task Management System

task management system in python

Stay organized and productive with a Task Management System in Python. Design an application that allows users to create, update, and track tasks and deadlines. Implement features such as task categorization, priority levels, and reminder notifications. This project will deepen your understanding of data management and user interaction in Python.

39. To-do List

python to-do list

Simplify your daily tasks with a To-do List application in Python. Design a program that allows users to create, edit, and delete tasks, along with setting deadlines and reminders. Implement features such as task categorization, sorting, and search functionalities. This project will enhance your skills in working with lists and user interfaces in Python.

40. WebScraper

python webscraper

Explore web scraping techniques by developing a WebScraper in Python. Design a program that extracts data from websites and saves it for further analysis or processing. Implement features such as data extraction, parsing, and storage. This project will deepen your understanding of web technologies and data manipulation in Python.

41. Paint Application

paint application in python

Unleash your creativity with a Paint Application in Python. Design a program that allows users to draw, paint, and manipulate images using various tools and brushes. Implement features such as color selection, brush sizes, and saving and exporting artwork. This project will enhance your understanding of graphical user interfaces (GUIs) and image processing in Python.

42. School Management System

python school management system

Streamline educational processes with a School Management System in Python. Design an application that manages student records, class schedules, grades, and attendance. Implement features such as user authentication, data encryption, and reporting functionalities. This project will deepen your understanding of data management and security in Python.

43. Translator / Language Converter

language converter in python

Bridge language barriers with a Translator or Language Converter application in Python. Design a program that translates text or phrases between different languages using translation APIs or libraries. Implement features such as language detection, input validation, and user-friendly interfaces. This project will introduce you to working with external APIs and text processing in Python.

44. Hangman Game

python hangman game

Challenge your vocabulary and logic skills with a Hangman Game in Python. Design a program that randomly selects a word for the player to guess, with limited attempts. Implement features such as displaying the hangman figure and tracking incorrect guesses. This project will reinforce your understanding of strings, loops, and user interaction in Python.

45. Chess Game

chess game in python

Enter the world of strategy and tactics with a Chess Game in Python. Design a program that simulates a chessboard, pieces, and rules, allowing players to compete against each other or against a computer AI. Implement features such as legal move validation, check detection, and checkmate conditions. This project will challenge you to implement complex game logic and algorithms in Python.

46. Minesweeper Game

python tkinter minesweeper game

Test your puzzle-solving skills with a Minesweeper Game in Python. Design a program that generates a grid of cells containing hidden mines, and allows the player to uncover cells without detonating any mines. Implement features such as mine placement, cell revealing, and game logic. This project will reinforce your understanding of nested loops, conditionals, and algorithms in Python.

47. Ping Pong Game

python ping pong game

Experience the excitement of classic arcade gaming with a Ping Pong Game in Python. Design a program that simulates a virtual ping pong table, allowing two players to compete against each other. Implement features such as paddle movement, ball physics, and scoring. This project will enhance your understanding of game mechanics and event handling in Python.

48. Snake Game

python snake game

Relive the nostalgia of old-school gaming with a Snake Game in Python. Design a program that simulates a snake moving around a grid, eating food to grow longer while avoiding collisions with itself and the walls. Implement features such as snake movement, food generation, and scoring. This project will deepen your understanding of game logic and data structures in Python.

49. Memory Tile Game

memory tile game in python

Challenge your memory and concentration with a Memory Tile Game in Python. Design a program that generates a grid of tiles, each containing a hidden image or symbol. Implement features such as tile flipping, matching pairs, and scoring. This project will reinforce your understanding of graphical user interfaces (GUIs) and event handling in Python.

50. Sudoku Solver

python sudoku solver

Master the art of puzzle-solving with a Sudoku Solver in Python. Design a program that can solve Sudoku puzzles of varying difficulties using algorithms such as backtracking or constraint propagation. Implement features such as puzzle input, solution validation, and step-by-step solving. This project will challenge you to implement advanced algorithms and enhance your problem-solving skills in Python.

51. Tic Tac Toe Game

tic tac toe game using python

Enjoy a timeless classic with a Tic Tac Toe Game in Python. Design a program that simulates a Tic Tac Toe board, allowing two players to take turns marking spaces until one player wins or the board is full (resulting in a draw). Implement features such as player input, win detection, and replayability. This project will reinforce your understanding of game logic and conditional statements in Python.

52. 2048 Game

2048 game in python

Experience the addictive gameplay of 2048 with a Python implementation of the game. Design a program that generates a grid of numbered tiles, allowing players to combine matching tiles by sliding them across the board. Implement features such as tile movement, merging, and scoring. This project will deepen your understanding of game mechanics and algorithms in Python.

Python projects with source code offer an excellent opportunity to enhance your programming skills and explore various domains. Whether you're interested in web development, data analysis, machine learning, or just looking for fun projects to try, there's something for everyone in this diverse collection. Start coding, learning, and building with Python today!

Q1. How can I get started with Python projects?

Begin by learning the basics of Python programming and then gradually progress to more complex projects. You can find project ideas online or create your own based on your interests.

Q2. Are there any prerequisites for working on Python projects?

Having a basic understanding of Python syntax and programming concepts is helpful. Additionally, familiarity with relevant libraries and frameworks for your chosen project domain can be beneficial.

Q3. Where can I find Python project ideas?

You can find project ideas on websites, forums, and GitHub repositories dedicated to Python projects. Additionally, brainstorming based on your interests and goals can help generate project ideas.

Q4. How do Python projects contribute to skill development?

Python projects provide hands-on experience, allowing developers to apply theoretical knowledge to practical scenarios. They also encourage problem-solving and foster creativity, leading to skill development.

Q5. Why is community involvement important in Python projects?

Community involvement allows developers to learn from others, collaborate on projects, and receive feedback on their work. It also fosters a sense of belonging and contributes to the growth of the Python community.

Build WhatsApp Chatbox Clone  HTML, CSS, JS Tutorial.jpg

That’s a wrap!

Thank you for taking the time to read this article! I hope you found it informative and enjoyable. If you did, please consider sharing it with your friends and followers. Your support helps me continue creating content like this.

Stay updated with our latest content by signing up for our email newsletter ! Be the first to know about new articles and exciting updates directly in your inbox. Don't miss out—subscribe today!

If you'd like to support my work directly, you can buy me a coffee . Your generosity is greatly appreciated and helps me keep bringing you high-quality articles.

Thanks! Faraz 😊

Subscribe to my Newsletter

Get the latest posts delivered right to your inbox, latest post.

Create Dice Rolling Game using HTML, CSS, and JavaScript

Create Dice Rolling Game using HTML, CSS, and JavaScript

Learn how to create a dice rolling game using HTML, CSS, and JavaScript. Follow our easy-to-understand guide with clear instructions and code examples.

Create Janmashtami Dahi Handi Animation with HTML, CSS, and JavaScript

Create Janmashtami Dahi Handi Animation with HTML, CSS, and JavaScript

August 21, 2024

Create Indian Independence Day Flag Animation using HTML, CSS & GSAP

Create Indian Independence Day Flag Animation using HTML, CSS & GSAP

August 15, 2024

How to Write a Plan Expiry Alert Email with an HTML Template

How to Write a Plan Expiry Alert Email with an HTML Template

August 13, 2024

Create Animated Logout Button Using HTML and CSS

Create Animated Logout Button Using HTML and CSS

August 08, 2024

Learn to create an animated logout button using simple HTML and CSS. Follow step-by-step instructions to add smooth animations to your website’s logout button.

Create Fortnite Buttons Using HTML and CSS - Step-by-Step Guide

Create Fortnite Buttons Using HTML and CSS - Step-by-Step Guide

June 05, 2024

How to Create a Scroll Down Button: HTML, CSS, JavaScript Tutorial

How to Create a Scroll Down Button: HTML, CSS, JavaScript Tutorial

March 17, 2024

How to Create a Trending Animated Button Using HTML and CSS

How to Create a Trending Animated Button Using HTML and CSS

March 15, 2024

Create Interactive Booking Button with mask-image using HTML and CSS (Source Code)

Create Interactive Booking Button with mask-image using HTML and CSS (Source Code)

March 10, 2024

Create a Breakout Game with HTML, CSS, and JavaScript | Step-by-Step Guide

Create a Breakout Game with HTML, CSS, and JavaScript | Step-by-Step Guide

July 14, 2024

Create a Whack-a-Mole Game with HTML, CSS, and JavaScript | Step-by-Step Guide

Create a Whack-a-Mole Game with HTML, CSS, and JavaScript | Step-by-Step Guide

June 12, 2024

Create Your Own Bubble Shooter Game with HTML and JavaScript

Create Your Own Bubble Shooter Game with HTML and JavaScript

May 01, 2024

Build a Number Guessing Game using HTML, CSS, and JavaScript | Source Code

Build a Number Guessing Game using HTML, CSS, and JavaScript | Source Code

April 01, 2024

Tooltip Hover to Preview Image with Tailwind CSS

Tooltip Hover to Preview Image with Tailwind CSS

Learn how to create a tooltip hover effect to preview images using Tailwind CSS. Follow our simple steps to add this interactive feature to your website.

Create Image Color Extractor Tool using HTML, CSS, JavaScript, and Vibrant.js

Create Image Color Extractor Tool using HTML, CSS, JavaScript, and Vibrant.js

January 23, 2024

Build a Responsive Screen Distance Measure with HTML, CSS, and JavaScript

Build a Responsive Screen Distance Measure with HTML, CSS, and JavaScript

January 04, 2024

Crafting Custom Alarm and Clock Interfaces using HTML, CSS, and JavaScript

Crafting Custom Alarm and Clock Interfaces using HTML, CSS, and JavaScript

November 30, 2023

Detect User's Browser, Screen Resolution, OS, and More with JavaScript using UAParser.js Library

Detect User's Browser, Screen Resolution, OS, and More with JavaScript using UAParser.js Library

October 30, 2023

Creating a Responsive Footer with Tailwind CSS (Source Code)

Creating a Responsive Footer with Tailwind CSS (Source Code)

Learn how to design a modern footer for your website using Tailwind CSS with our detailed tutorial. Perfect for beginners in web development.

Crafting a Responsive HTML and CSS Footer (Source Code)

Crafting a Responsive HTML and CSS Footer (Source Code)

November 11, 2023

Create an Animated Footer with HTML and CSS (Source Code)

Create an Animated Footer with HTML and CSS (Source Code)

October 17, 2023

Bootstrap Footer Template for Every Website Style

Bootstrap Footer Template for Every Website Style

March 08, 2023

How to Create a Responsive Footer for Your Website with Bootstrap 5

How to Create a Responsive Footer for Your Website with Bootstrap 5

August 19, 2022

CopyAssignment

We are Python language experts, a community to solve Python problems, we are a 1.2 Million community on Instagram, now here to help with our blogs.

  • Best 100+ Python Projects with source code

Best 100+ Python Projects with source code

We recommend you bookmark this page before you lost it as you will surely need this in the future because we have presented the best Python Projects with source code in every field like web development, computer vision, data science, machine learning, game development, GUI/Desktop applications, Turtle, etc. Now, let’s start .

Best Python Projects with source code

We have presented all the best python project ideas below based on difficulty level so that anyone from beginner to advanced level python programmers can select simple python projects according to their levels.

Python Projects for beginners

Python beginners’ projects will be mini python projects which are good for python programmers who have just started their journey in Python. We are presenting the best python mini projects with source code and links.

Here is the list of Simple Python mini projects for beginners:

  • Number Guessing game in Python
  • Rock Paper Scissors Game
  • Dice Roller
  • Simple Calculator GUI
  • Tic-Tac-Toe
  • Countdown Timer
  • QR-code Generator
  • Taking ScreenShots
  • Desktop Notifier
  • Age Calculator
  • Story Generator program
  • Website blocker Program
  • Image To Text or Extract text from images
  • Strong Password Generator
  • Count words from Paragraph

Intermediate Python Projects

At the Intermediate level, we thought that projects on Python desktop applications are best for all programmers, so we will present intermediate python projects which will mostly result in desktop applications.

Here is the list of top Python coding projects for Intermediates:

  • Library Management System Project
  • Student Management System Project
  • Employee Management System Project
  • Bank Management System Project
  • Restaurant Management System Project
  • Python Snake Game
  • Flappy Bird Game
  • File Manager Python Project
  • Music Player
  • Quiz Application
  • Expense Tracker
  • Site Connectivity Checker
  • Bitcoin Price Notifications
  • Amazon Price Tracker
  • Build a contact book
  • Text to speech
  • Voice assistant like Jarvis
  • Tetris game in PyGame

Advanced Python projects

These python coding projects are for programmers who are experts in python. These projects are not simple python projects, we recommend you to try these projects only if you are an expert in Python libraries and have already created many projects. These projects are most suitable for your resume.

Here is the list of best Python coding projects for Advanced:

  • Stock Price Tracker
  • Stock Price Prediction
  • E-commerce Website
  • College Registration website
  • Face Recognition
  • Traffic Signal Violation Detection
  • Automatic Traffic Control
  • Control PC from anywhere
  • Noise Cancellation
  • Plastic Waste Detection
  • Send emails using Python
  • Satellite Imagery Analysis using Python
  • Login with Face
  • Text from video
  • Calories Tracker web app
  • Parking Space Detection

Django Projects with source code in Python

Django is the best Python framework for web development using Python. You can create many Django projects without any limitations as Django is completely open-source. Today, we will present the best Django project with source code. We are presenting all types of Django project ideas, you can select any one or more according to your level whether it is beginner, intermediate, or advanced. If your level is advanced, you should select Django projects for resume.

Here is the list of best Django projects with source code links:

  • Syntax Highlighter
  • Dictionary Application
  • Simple Notes Making App
  • Blog(beginner level)
  • Simple Register and Login System
  • Simple online calculator
  • Poll web App
  • Calories Tracker
  • Weather web App
  • Online Music Player
  • Automatic Tweet Posting
  • Portfolio website
  • Email App with Django
  • Library Management System
  • Resume Builder
  • Chat Application
  • Video Chat App
  • Social Media Application
  • Pinterest Clone
  • Netflix Clone
  • Loan Management System
  • Real State Management System
  • Laundry Shop Management System
  • File Sharing website
  • Payment System

OpenCV Projects with source code in Python

Here is the list of best OpenCV projects for beginners to advanced:

  • Smart face recognition attendance system using python
  • Traffic Signal Violation Detection System
  • Smart Fire Detection System
  • Social Distancing Checker System
  • Real-Time Face Recognition
  • Controlling Mouse With Hands
  • Playing Snake Game with Gestures
  • Face Mask Detection
  • Object Detection
  • Color Detection
  • Counting Human Faces
  • Vehicle Counting, Classification & Detection
  • Add WaterMark to images
  • Virtual Painting App
  • Automatic Selfie Capture on Smile
  • Self Driving Car
  • Currency Recognition
  • Smart Navigation System for Blind People
  • Online Examination PROCTORING System
  • Traffic light Controller System
  • Logo Detection
  • Tumor Detection
  • Handwritten Digit Classification
  • Drowsiness Detection
  • Food Calories Estimation Using Image Processing
  • Helmet Detection

Python Projects for resume

We have a separate article on Python Projects for Resumes. It’s one of the best available on the Internet. You must try once .

20 Python Projects for Resume

Cool and fun Python Projects

Cool and fun Python projects must include interesting games and exciting GUI applications. Whatever we do in gaming is all fun and exciting. We have tried to find out all the best cool python projects for beginners and intermediates.

Here is the list of most interesting Python projects with source code:

  • URL Shortner
  • MP3 Music Player
  • Paint Application
  • Snake Game using Turtle
  • Drawing Doraemon
  • Drawing Pikachu
  • Drawing IronMan Helmet
  • Jarvis like Voice Assistant
  • Automate Website Login
  • Gender Recognition by voice
  • File Explorer in Python
  • Notepad like Text Editor using Python
  • Fake News Detection
  • Story Generator
  • Rock Paper Scissor Game
  • Draw Various Shapes in Python
  • Generate QR-Code for a website
  • Minecraft in Python
  • Happy Birthday in Python

Python projects for Turtle Graphics

The purpose of creating a library like turtle is very clear, learning programming and logic by drawing simple drawings using Python Turtle graphics. If you are a beginner in the programming world, then you should start with the turtle. You can even create famous games using the python turtle like snake game.

Here is the list of top 30 turtle projects with source code and links:

  • Radha Krishna using Python Turtle
  • Drawing letter A using Python Turtle
  • Wishing Happy New Year 2023 in Python Turtle
  • Snake and Ladder Game in Python
  • Draw Goku in Python Turtle
  • Draw Mickey Mouse in Python Turtle
  • Happy Diwali in Python Turtle
  • Draw Halloween in Python Turtle
  • Write Happy Halloween in Python Turtle
  • Draw Happy Diwali in Python Turtle
  • Extract Audio from Video using Python
  • Drawing Application in Python Tkinter
  • Draw Flag of USA using Python Turtle
  • Draw Iron Man Face with Python Turtle: Tony Stark Face
  • Draw TikTok Logo with Python Turtle
  • Draw Instagram Logo using Python Turtle
  • I Love You Text in ASCII Art
  • Python Turtle Shapes- Square, Rectangle, Circle
  • Python Turtle Commands and All Methods
  • Happy Birthday Python Program In Turtle
  • I Love You Program In Python Turtle
  • Draw Python Logo in Python Turtle
  • Space Invaders game using Python
  • Draw Google Drive Logo Using Python
  • Draw Instagram Reel Logo Using Python
  • Draw The Spotify Logo in Python Turtle
  • Draw The CRED Logo Using Python Turtle
  • Draw Javascript Logo using Python Turtle
  • Draw Dell Logo using Python Turtle
  • Draw Spider web using Python Turtle

Automation Python Projects

Here is the list of automation Python projects:

  • Instagram Automation
  • ChatBot Automation
  • Algorithmic Trading using Python
  • Automate email marketing campaigns
  • Auto Update Excel Sheets
  • Automatic Online Form Filling
  • Twitter bot automation
  • Tic-Tac-Toe Automation
  • Automate Bills Payment
  • Automating Your Digital Morning Routine with Python
  • Automate WhatsApp

Python Tkinter GUI Projects

Python Tkinter is the best Python library to create desktop applications using Python. We are going to present you with the best Python Tkinter projects with source code and links. These projects will be of different types, some will contain databases and some will be very simple. Click here to get the top 10 Tkinter project ideas for beginners.

Here is the list of top 30 Tkinter projects in Python:

  • Create your own ChatGPT with Python
  • SQLite | CRUD Operations in Python
  • Event Management System Project in Python
  • Ticket Booking and Management in Python
  • Hostel Management System Project in Python
  • Sales Management System Project in Python
  • Bank Management System Project in C++
  • Python Download File from URL | 4 Methods
  • Python Programming Examples | Fundamental Programs in Python
  • Spell Checker in Python
  • Portfolio Management System in Python
  • Stickman Game in Python
  • Contact Book project in Python
  • Loan Management System Project in Python
  • Cab Booking System in Python
  • Brick Breaker Game in Python
  • Tank game in Python
  • GUI Piano in Python
  • Ludo Game in Python
  • Rock Paper Scissors Game in Python
  • Puzzle Game in Python
  • Medical Store Management System Project in Python
  • Creating Dino Game in Python
  • Tic Tac Toe Game in Python
  • Test Typing Speed using Python App
  • Scientific Calculator in Python
  • GUI To-Do List App in Python Tkinter
  • Scientific Calculator in Python using Tkinter
  • GUI Chat Application in Python Tkinter

Python Projects for Machine Learning and Data Science

Here is the list of the best 30 python projects for machine learning and data science with source code:

  • Flower classification using CNN
  • Music Recommendation System in Machine Learning
  • Top 15 Machine Learning Projects in Python with source code
  • Gender Recognition by Voice using Python
  • Top 15 Python Libraries For Data Science in 2022
  • Setup and Run Machine Learning in Visual Studio Code
  • Diabetes prediction using Machine Learning
  • Customer Behaviour Analysis – Machine Learning and Python
  • Data Science Projects for Final Year
  • Multiclass Classification in Machine Learning
  • Movie Recommendation System: with Streamlit and Python-ML
  • Machine Learning Projects for Final Year
  • Reinforcement learning in Python
  • Face recognition Python
  • Hate speech detection with Python
  • MNIST Handwritten Digit Classification using Deep Learning
  • Stock Price Prediction using Machine Learning
  • Control Mouse with hand gestures detection python
  • Traffic Signal Violation Detection System using Computer Vision
  • Deepfake Detection Project Using Deep-Learning
  • Employment Trends Of Private & Government Sector in UAE | Data Analysis
  • Pokemon Analysis Project in ML and Data Science using Python
  • Garment Factory Analysis Project using Python
  • Titanic Survival Prediction – Machine Learning Project (Part-2)
  • Titanic Survival Prediction – Machine Learning Project (Part-1)

Game development projects in Python

Here is the list of best 30 python projects for games:

  • Tetris game in Python Code
  • Python Games Code | Copy and Paste
  • How to make KBC Quiz game in python?
  • Creating a Pong Game using Python Turtle
  • Hangman Game using Python
  • Balloon Shooter Game using Python PyGame
  • Complete PyGame Tutorial and Projects
  • Flappy Bird In Python Pygame with source code
  • Tic Tac Toe in Python
  • Make A Telegram Bot Using Python
  • How to Draw the Superman Logo Using Python Turtle
  • 3D animation in Python: vpython
  • Complete Racing Game In Python Using PyGame
  • Complete Game In PyGame and Python
  • Snake Game with Python Turtle Graphics
  • Star Wars Game with Python Turtle
  • Turtle Race Python Project: Complete Guide
  • Car Race Game in PyGame Python: From Scratch

Python projects for final year students of Computer Science

We already have a good article on python projects for final-year students. Click here to check the best Python projects for final-year students.

Top 10 Python Projects for Final year Students

You can check more final year projects below, here is the list:

  • Download 1000+ Projects, All B.Tech & Programming Notes, Job, Resume & Interview Guide, and More – Get Your Ultimate Programming Bundle!
  • 100+ Java Projects for Beginners 2023
  • Courier Tracking System in HTML CSS and JS
  • Top 15 Java Projects For Resume
  • Top 10 Java Projects with source code
  • Top 10 Final Year Projects for Computer Science Students
  • Library Management System Project in Java
  • Bank Management System Project in Java
  • CS Class 12th Python Projects
  • Top 10 Python Projects for Final year Students
  • Python OOP Projects | Source code and example
  • Inventory Management System Project in python
  • Courier Management System project in Python
  • Contact Management System Project in Python
  • Python SQLite Tutorial
  • Student Management System Project in Python
  • 20 Python Projects for Resume
  • Restaurant management system project in Python
  • Employee Management System Project in Python
  • Bank Management System Project in Python

Final thoughts

Don’t forget to bookmark this page and share it with your friend, you may lose it. We have really worked hard and researched too much for most of the projects in this blog so that our users like you can save their time by directly selecting their favorite python project from the best projects available on the Internet. We selected only the best projects so that you can learn and try from the top and best projects only. That’s all for this tutorial, we hope you will find your dream Python project.

Thank you for reading till here.

Keep learning

' src=

Author: Harry

python assignment project

Search….

python assignment project

Machine Learning

Data Structures and Algorithms(Python)

Python Turtle

Games with Python

All Blogs On-Site

Python Compiler(Interpreter)

Online Java Editor

Online C++ Editor

Online C Editor

All Editors

Services(Freelancing)

Recent Posts

  • Most Underrated Database Trick | Life-Saving SQL Command
  • Python List Methods
  • Top 5 Free HTML Resume Templates in 2024 | With Source Code
  • How to See Connected Wi-Fi Passwords in Windows?
  • 2023 Merry Christmas using Python Turtle

© Copyright 2019-2024 www.copyassignment.com. All rights reserved. Developed by copyassignment

  • Python Course
  • Python Basics
  • Interview Questions
  • Python Quiz
  • Popular Packages
  • Python Projects
  • Practice Python
  • AI With Python
  • Learn Python3
  • Python Automation
  • Python Web Dev
  • DSA with Python
  • Python OOPs
  • Dictionaries

Python Projects – Beginner to Advanced

In this guide, we’ll explore a range of Python projects suitable for beginners to advanced programmers. These Python projects are designed to help you gain practical experience with Python programming while building real-world applications. Whether you’re just starting out or looking to deepen your understanding of Python, there’s something here for everyone.

Python Projects

Recent Python Projects !!

Projects for Beginners

  • Number guessing game in Python
  • Word guessing game in Python
  • Hangman Game in Python
  • 21 Number game in Python
  • Mastermind Game using Python
  • 2048 Game in Python
  • Flames game in Python
  • Pokémon Training Game
  • Rock Paper Scissor game in Python
  • Taking Screenshots using pyscreenshot in Python
  • Desktop Notifier in Python
  • Get Live Weather Desktop Notifications Using Python
  • How to use pynput to make a Keylogger?
  • Python – Cows and Bulls game
  • Simple Attendance Tracker using Python
  • Higher-Lower Game with Python
  • Fun Fact Generator Web App in Python
  • Check if two PDF documents are identical with Python
  • Creating payment receipts using Python
  • How To Create a Countdown Timer Using Python?
  • Convert emoji into text in Python
  • Create a Voice Recorder using Python
  • Create a Screen recorder using Python

Projects for Intermediate

  • How to Build a Simple Auto-Login Bot with Python
  • Make a Twitter Bot in Python
  • Building WhatsApp bot on Python
  • Create a Telegram Bot using Python
  • Twitter Sentiment Analysis using Python
  • Employee Management System using Python
  • How to make a Python auto clicker?
  • Instagram Bot using Python and InstaPy
  • File Sharing App using Python
  • Send message to Telegram user using Python
  • Whatsapp birthday bot
  • Corona HelpBot
  • Amazon product availability checker using Python
  • Fetch your gmail emails from a particular user
  • How to Create a Chatbot in Android with BrainShop API?
  • Spam bot using PyAutoGUI
  • Hotel Management System

Web Scraping

  • Build a COVID19 Vaccine Tracker Using Python
  • Email Id Extractor Project from sites in Scrapy Python
  • Automating Scrolling using Python-Opencv by Color Detection
  • How to scrape data from google maps using Python?
  • Scraping weather data using Python to get umbrella reminder on email
  • Scraping Reddit using Python
  • How to fetch data from Jira in Python?
  • Scrape most reviewed news and tweet using Python
  • Extraction of Tweets using Tweepy
  • Predicting Air Quality Index using Python
  • Scrape content from dynamic websites

Automating boring Stuff Using Python

  • Automate Instagram Messages using Python
  • Automating Happy Birthday post on Facebook
  • Automatic Birthday mail sending with Python
  • Automated software testing with Python
  • Automate Google Search
  • Automate linkedin connections using Python
  • Automated Trading using Python
  • Automate the Conversion from Python2 to Python3
  • Bulk Posting on Facebook Pages using Selenium
  • Share WhatsApp Web without Scanning QR code using Python
  • Automate WhatsApp Messages With Python using Pywhatkit module
  • How to Send Automated Email Messages in Python
  • Automate backup with Python Script
  • Hotword detection with Python

Tkinter Projects

  • Create First GUI Application using Python-Tkinter
  • Simple GUI calculator using Tkinter
  • Compound Interest GUI Calculator using Tkinter
  • Loan calculator using Tkinter
  • Rank Based Percentile Gui Calculator using Tkinter
  • Standard GUI Unit Converter using Tkinter in Python
  • Create Table Using Tkinter
  • GUI Calendar using Tkinter
  • File Explorer in Python using Tkinter
  • ToDo GUI Application using Tkinter
  • Weight Conversion GUI using Tkinter
  • Age Calculator using Tkinter
  • Create a GUI Marksheet using Tkinter
  • Create a digital clock using Tkinter
  • Create Countdown Timer using Python-Tkinter
  • Tkinter Application to Switch Between Different Page Frames
  • Color game using Tkinter in Python
  • Simple FLAMES game using Tkinter
  • Simple registration form using Tkinter
  • Image Viewer App in Python using Tkinter
  • How to create a COVID19 Data Representation GUI?
  • Create GUI for Downloading Youtube Video using Python
  • GUI to Shutdown, Restart and Logout from the PC using Python
  • Create a GUI to extract Lyrics from song Using Python
  • Application to get live USD/INR rate Using Python
  • Build an Application for Screen Rotation Using Python
  • Build an Application to Search Installed Application using Python
  • Text detection using Python
  • Spell Corrector GUI using Tkinter
  • Make Notepad using Tkinter
  • Sentiment Detector GUI using Tkinter
  • Create a GUI for Weather Forecast using openweathermap API in Python
  • Build a Voice Recorder GUI using Python
  • Create a Sideshow application in Python
  • Visiting Card Scanner GUI Application using Python

Turtle Projects

  • Create digital clock using Python-Turtle
  • Draw a Tic Tac Toe Board using Python-Turtle
  • Draw Chess Board Using Turtle in Python
  • Draw an Olympic Symbol in Python using Turtle
  • Draw Rainbow using Turtle Graphics in Python
  • How to make Indian Flag using Turtle – Python
  • Draw moving object using Turtle in Python
  • Create a simple Animation using Turtle in Python
  • Create a Simple Two Player Game using Turtle in Python
  • Flipping Tiles (memory game) using Python3
  • Create pong game using Python – Turtle

OpenCV Projects

  • Extract frames using OpenCV
  • Displaying the coordinates of the points clicked on the image using Python-OpenCV
  • White and black dot detection
  • OpenCV BGR color palette with trackbars
  • Draw rectangular shape and extract objects
  • Drawing with Mouse on Images using Python-OpenCV
  • Text Detection and Extraction using OpenCV and OCR
  • Invisible Cloak using OpenCV
  • Background subtraction – OpenCV
  • Unsupervised Face Clustering Pipeline
  • Pedestrian Detection using OpenCV-Python
  • Saving Operated Video from a webcam
  • Face Detection using Python and OpenCV with webcam
  • Gun Detection using Python-OpenCV
  • Multiple Color Detection in Real-Time using Python-OpenCV
  • Detecting objects of similar color in Python using OpenCV
  • Opening multiple color windows
  • Play a video in reverse mode
  • Template matching using OpenCV in Python
  • Cartooning an Image using OpenCV – Python
  • Vehicle detection in a Video frame using Python – OpenCV
  • Count number of Faces using Python – OpenCV
  • Live Webcam Drawing using OpenCV
  • Detect and Recognize Car License Plate from a video in real time
  • Track objects with Camshift using OpenCV
  • Replace Green Screen using OpenCV- Python
  • Python – Eye blink detection project
  • Connect your android phone camera to OpenCV – Python
  • Determine The Face Tilt Using OpenCV – Python
  • Right and Left Hand Detection Using Python
  • Brightness Control With Hand Detection using OpenCV in Python
  • Creating a Finger Counter Using Computer Vision and OpenCV in Python

Python Django Projects

  • Python Web Development – Django Tutorial
  • How to Create an App in Django?
  • Weather app using Django
  • Django Sign Up and login with confirmation Email
  • ToDo webapp using Django
  • Setup Sending Email in Django Project
  • Django project to create a Comments System
  • Voting System Project Using Django Framework
  • Translator App Project using Django
  • How to add Google reCAPTCHA to Django forms?
  • Youtube video downloader using Django
  • E-commerce Website using Django
  • College Management System using Django – Python Project
  • Create Word Counter app using Django

Python Text to Speech and Vice-Versa

  • Speak the meaning of the word using Python
  • Convert PDF File Text to Audio Speech using Python
  • Speech Recognition in Python using Google Speech API
  • Convert Text to Speech in Python
  • Python Text To Speech using pyttsx module
  • Convert Speech to text and text to Speech
  • Personal Voice Assistant in Python
  • Build a Virtual Assistant Using Python
  • Create a simple assistant using Wolfram Alpha API
  • Voice Assistant using python
  • Voice search Wikipedia using Python
  • Language Translator Using Google API in Python
  • How to make a voice assistant for E-mail in Python?
  • Voice Assistant for Movies using Python

More Projects on Python

  • Tic Tac Toe GUI In Python using PyGame
  • 8-bit game using pygame
  • Bubble sort visualizer using PyGame
  • Caller ID Lookup using Python
  • Tweet using Python
  • How to make Flappy Bird Game in Pygame?
  • Face Mask detection and Thermal scanner for Covid care – Python Project
  • Personalized Task Manager in Python
  • Pollution Control by Identifying Potential Land for Afforestation – Python Project
  • Human Scream Detection and Analysis for Controlling Crime Rate – Project Idea
  • Download Instagram profile pic using Python

Projects are a fun way to learn and practice coding. They help you build practical skills like making games, automating tasks, analyzing data, and creating web apps. Each project you tackle in this Python projects post helps you become better at Python and prepares you for using it in real-life situations. Along with this if you are looking of for upscale you Python knowledge, then enroll our free Python course .

Python Projects – Beginner to Advanced – FAQs

How do i go from beginners to advanced python.

To advance from beginner to expert in Python, expand your skills by learning complex topics like object-oriented programming and data structures. Dive into libraries like NumPy and Pandas, and practice by working on personal or open-source projects. Regularly challenging yourself with new problems and engaging with the Python community will also help sharpen your skills.

What is a good starting project for Python?

A good starting project for Python is creating a simple calculator. It helps you practice basic concepts like variables, functions, and conditionals. As you get more comfortable, you can add features like handling more complex calculations or incorporating a graphical user interface using libraries like Tkinter. This project is manageable for beginners and offers plenty of scope for expansion as you learn more.

Where can I learn Python from basic to advanced?

You can learn Python from basic to advanced levels on GeeksforGeeks. They offer a wide range of tutorials, examples, and exercises that cover everything from the very basics to more advanced topics. This platform allows you to gradually build your skills at a comfortable pace, with plenty of resources to help you along the way.

How long does it take to learn Python from beginner to advanced?

The time it takes to learn Python from beginner to advanced can vary widely based on your background, the amount of time you invest, and how deeply you want to understand the language. Generally, with consistent study and practice, you can achieve a good level of proficiency in 3 to 6 months. To reach an advanced level, especially with specialization in areas like data science or web development, might take a year or more of dedicated learning.

Please Login to comment...

Similar reads.

  • Python-projects

Improve your Coding Skills with Practice

 alt=

What kind of Experience do you want to share?

Geekflare

15 Beginner Python Projects to Practice and Learn

Beginner Python Projects to Practice and Learn

In this article, we’ll go over Python projects with code that’ll help you build a portfolio, and level up your Python programming skills.

We’ll start by discussing Python projects for beginners and going through a list of easy Python projects for beginners. I’ve also included a bit of information on Python, with tips on choosing a development environment and how to learn Python effectively.

For all of this and more, let’s begin!

Easy Python Projects for Beginners in 2024

As building projects and practicing problems is the key to effective learning, we’ve put together a list of 15 beginner-friendly Python projects and coding questions—all explained with code.

These practice problems and projects will start by focusing on fundamentals. The list will then gradually introduce you to different Python modules, and programming paradigms like object-oriented programming (OOP) – to help you go from a beginner to an intermediate Python programmer.

Let’s get started.

Solve Problems on Python Strings

A a beginner Python programmer, you should be familiar with Python strings and string operations. To help you level up, we’ve put together a tutorial covering interesting problems around Python strings.

Problems you’ll solve:

  • Check whether a given Python string is a palindrome .
  • Verify whether or not two strings are anagrams .
  • Given a string containing the first name and last name, check if the name string is formatted in the title case .

Along the way, you’ll also learn important concepts like string slicing and string reversal in Python.

▶️ Read Python Programs on String Operations .

Work with Dates and Times in Python

Another important module in core Python is datetime . Python has a built-in date time module that helps you work with dates and times efficiently.

We have a guide on working with dates and times and Python—with a focus on calculating time difference.

What you’ll learn:

  • Working with date , time , and datetime objects in Python
  • Using the timedelta object in Python to calculate time difference

What you’ll solve:

  • Retrieve the current date and time in Python
  • Calculate the time left for your birthday
  • Compute the number of days left for this year’s Teachers’ Day, Christmas, and more

▶️ Check out our guide on working with date and time objects in Python.

Check if a Number is Prime in Python

As a next step, you can go through Python tutorials covering basic math and logic. Here’s a popular question: How to check if a number is prime in Python?

What you’ll code:

  • O(n) algorithm check if a number is prime or not
  • O(√n) algorithm to check for prime number—using the fact that factors of a number occur in pairs

▶️ Read the tutorial on prime number checking , explaining the algorithm and time complexity.

Multiply Matrices in Python

Matrices and questions around matrices will pop up often in coding interviews. To help you get started, we have put together an in-depth tutorial on matrix multiplication in Python.

  • Coding custom Python function to multiply matrices
  • Using nested list comprehension to perform matrix multiplication
  • Using NumPy built-in functions to multiply matrices

▶️ For a quick coding exercise, check out the tutorial on matrix multiplication in Python.

Work with Text Files in Python

In any programming language, file handling is an important aspect. And we have put together an in-depth guide on file handling in Python.

  • Working with text files in Python
  • Common file I/O operations
  • Working with data in files

▶️ Learn how to handle files in Python.

Print Pascal’s Triangle in Python

Now that we’re focusing on math problems, printing Pascal’s triangle is a frequently asked question in technical interviews.

  • how to construct Pascal’s Triangle
  • how to implement a Python function to print Pascal’s triangle for any given number of rows

▶️ Learn to print Pascal’s triangle in Python.

Check for Valid Parentheses in Python

Checking for valid parentheses string is a popular interview question, and we have a tutorial to help you solve it!

  • Use Python’s built-in data structures: lists and dictionaries to solve the problem efficiently
  • Validate any given parentheses string

▶️ Check out the tutorial on valid parentheses checking in Python.

Once you’ve ramped up on core Python fundamentals, it’s important to learn the basic searching and sorting algorithms, and we’ve got you covered with comprehensive tutorials on the same.

Searching Algorithms in Python

If you’d like to search for a specific element in an array, you’ll take the help of search algorithms.

  • Linear search with O(n) complexity, for input array of size n
  • Binary search with O(log n) complexity

While linear search is the best you can do when the input array is not sorted, binary search is the most efficient when you have a sorted array. This is because binary search works by reducing the search interval into half at each successive step.

▶️ Read the tutorial on search algorithms in Python to learn more.

Sorting Algorithms in Python

Once you’ve gotten the hang of how to search through lists, it’s helpful to learn how to sort lists . We have a tutorial that’ll teach you how to code some of the basic sorting algorithms in Python.

  • Insertion sort
  • Selection Sort
  • Bubble Sort

▶️ Check out the guide on sorting algorithms in Python.

Build a Number Guessing Game

Number guessing game where you try to guess a secret number in the minimum number of guesses is a fun coding project. 👩🏽‍💻

  • Validate user input against the secret number
  • Give users feedback on their guess, and also limit the maximum guesses allowed

▶️ Start building a number guessing game in Python.

Code a Password Generator in Python

Have you ever found it difficult to come up with secure passwords—across sites you frequently visit on the web? How about coding your own password generator in Python?

You can use Python to generate passwords that meet constraints such as, the number of special characters, password length, and more.

What you’ll build:

  • With the number of characters of each type as input, generate a secure password satisfying all the constraints
  • Use Python’s secrets module effectively

▶️ Learn to code a password generator in Python.

Send Emails Using Python

Here’s a simple automation project in Python. You can use Python to automate sending emails. Wishing your colleagues on a special occasion, and your friends on their birthdays has never been easier! 📧

  • Automate sending emails
  • Use smtplib , a Python implementation of the Simple Mail Transfer Protocol

▶️ Learn to send emails in Python.

Build Tic-Tac-Toe Game in Python

Tic-tac-toe is one game we’ve all played with our friends at some point in time. 😄 Wouldn’t it be cool if you could code it in Python, and invite your friends to play it as well?

Yes, and we have a tutorial that’ll you help you build your own tic-tac-toe game. You’ll translate the logic behind playing tic-tac-toe into Python code.

What you’ll use:

  • Basics of Object Oriented Programming (OOP)
  • Understanding class methods

▶️ Learn to code a tic-tac-toe game now!

Build a Multiplication Table App

Python is a general-purpose programming language that supports both functional and object-oriented programming (OOP) paradigms. To help you level up your OOP skills, we’ve a project for you.

  • Multiplication table app using OOP
  • Learn to use class methods and attributes

▶️ Check out the project on multiplication table app using OOP in Python.

Code Snake Game in Python

Remember the classic snake game? You’ll leverage all that you’ve learned to build the snake game in Python, with graphical user interface (GUI)—by translating the game’s logic into Python code.

  • A simple GUI in Python using the turtle library
  • Code the rules of the snake game, and set up the game environment

▶️ Start coding snake game in Python.

Now that we are done with those projects, let’s cover some basics!

Why Should You Learn Python?

Easy-to-read syntax, a variety of built-in modules, and a supportive community make Python a great first programming language to learn.

Once you’re familiar with programming fundamentals, you may want to choose a path to specialize in, and learn specific skills.

Read through the following list of specializations. Does any of them interest you?

  • Web Development
  • API Development
  • Data Analytics
  • Data Science
  • Data Engineering
  • Game Development

python-applications-projects

These are some of the most sought-after tracks; you could do all of these and much more with Python!

So if you’re looking to learn Python, the best time to start is now! ⏲

What are the Best Python IDEs and Code Editors to Use?

If you are beginner Python programmer, you’d likely need some help choosing the best development environment.

To solve coding problems and build simple modules, a code editor will suffice. As you start building larger projects with multiple modules, you may want to consider an integrated development environment (IDE). An IDE helps you manage installations, develop, and debug in the same environment.

Here are our top picks for Python code editors and IDEs.

#1. Sublime Text

With a friendly interface, support for Markdown, and multiple programming languages, Sublime Text is one of the code editors you can use for scripting in Python.

#2. Geekflare Online Python Code Editor

We have a library of Python tutorials, and you can open up Geekflare’s online Python editor and try running the code snippets, as you go through the tutorials You can do this right from your browser – no installation needed!

#3. Jupyter Notebook

Are you someone who likes to add descriptive text and images to document your project, in addition to writing code? If yes, Jupyter notebook could be a great choice to showcase your projects!

Apart from the traditional notebook interface, there are several Jupyter alternatives that provide better collaboration, and enhanced features.

#4. PyCharm

PyCharm from JetBrains is another popular IDE for Python. You can manage your projects inside virtual environments, install required packages, and profile your Python code. There is a free community edition that you can use.

#5. Visual Studio Code

Visual Studio Code, or VS Code from Microsoft is another free IDE that’s popular in the developer community. VS Code has extensions that support using a wide variety of tech stacks and programming languages, such as HTML, CSS, JavaScript, Go, and Python.

What is the Best Way to Learn Python?

Now that you have a list of options for your development and programming practice, let’s see how you can learn Python effectively.

There are three steps to learning any programming language effectively.

learn-python

Step 1: Learn the fundamentals

This would include learning the basic syntax, data types and built-in data structures, programming fundamentals such as conditional statements, loops, functions, and so on. You may learn Python fundamentals online from platforms like Udemy with Python bootcamps .

Step 2: Build projects

Learning the syntax is just the tip of the iceberg when it comes to mastering a programming language. The actual learning happens when you build projects applying what you’ve learned.

Step 3: Practice

At this point, you’ve understood the fundamentals, and have also built projects.

How do you ensure that you remain familiar with all that you’ve learned?

Well, deliberate practice is the key. This means you should revise and practice periodically, and flex your coding muscles.

Wrapping Up

I hope you found a few interesting practice problems and projects you can add to your portfolio. As you keep adding new skills to your Python toolbox, you should always remember to supplement your learning by building projects. Remember, consistent practice is the key to getting better at programming.

See you all in another Python tutorial soon! Happy learning!

More on Python

  • PHP vs Python
  • Python Logging Explained

InterviewBit

Top Python Projects for Beginners to Advanced [With Source Code]

Top 10 python projects for beginners, 1. email slicer, 2. number to words, 3. google image downloader, 4. contact list, 5. monty hall simulation problem, 6. image to sound, 7. snake game, 8. gif creator, 9. website blocker, 10. binary search algorithm, 11. dice rolling simulator, top 12 python project ideas for intermediate, 1. image to story, 2. number guessing, 3. fibonacci generator, 4. voice assistant, 5. password generator, 6. reddit bot, 7. black jack, 8. recursive triangle, 10. rock paper scissors game, 11. currency converter, 12. quiz application, top 5 python project ideas for advanced users, 1. content aggregator, 2. building chatbot, 3. face mask detection, 4. plagiarism checker, 5. music player, why are python projects important, 1. is python suitable for large projects, 2. how do you write a project in python, 3. what should my first python project be, 4. is python bad for big projects, 5. how to make projects in python, 6. how to run a python project, additional resources.

Python is an extremely popular programming language. Almost, 8.2M developers all over the globe use Python for their projects which is more than Java now. So, in order to master Python language, it is recommended to start by creating some projects. In this article, we are going to cover Python Project Ideas for beginners and experts with valid source codes.

Well, if you’ve just started out learning Python or are at a stage where you really want to get your hands dirty, then follow this section. We have discussed a few Python projects with source codes here for you to delve deep and get expertise:

One of the easiest projects to start with is an Email Slicer. The first question that comes to our mind is: what is an email slicer?

Confused about your next job?

In essence, Email Slicer is just a simple tool that will take an email address as input and slice it to produce the username and the domain associated with it. The email must be divided into two strings by using ‘@’ as the separator.

For example

  Output:

Here we got InterviewBit as the username and gmail.com as a domain.

Let’s get right to coding and build this quick and easy project. It doesn’t require any setup, so let’s get started!

You can check Source Code

This Python project can make you spell out the numbers you may define. This Python code will help you support more than a million inputs along with non-positive integers like zero, negative integers, or floating numbers. 

You can check the Source Code

Need a bunch of images for your new project? Then just run this program and download any number of images for a  topic. Only ensure that you do not violate copyright issues and give due credit to the owner if needed. 

As old school as it may sound, creating a contact list, adding contacts along with phone numbers or emails, and editing them, are still prevalent. To create one, you can use the SQLAlchemy library which uses SQLite to store contacts. Your contact book application should be organized into modules and packages, and you should give it a coherent structure.

In order to get the most out of this project, some previous experience with Python and PyQt programming would be helpful. As a result, you will need to know the following:

  • Develop GUI applications with PyQt and Python
  • Use Python and PyQt to manage SQL databases
  • Working with SQLite databases

So, In this project, you’ll learn how to:

  • Implement a GUI for your contact book application with Python and PyQt
  • Using PyQt’s SQL support to connect the application to an SQLite database 
  •  Using PyQt’s Model-View architecture for managing contact data

By the end of this project, you’ll have an application that allows you to manage and store your contacts.

You can check the Source Code :

Monty hall’s problem comes from a famous movie where three doors are used to help you win a car. How? Each door hides something behind it–a car and two goats. Any door can have the car while the remaining two have goats. The probability to find a car is ⅓. Now, if you select Door 1 and the host opens Door 3 to find a goat, your chances just become ⅔. This program will help you solve this problem. 

Work Flow and Logic 

The following are the main points of the simulation:

  • As there are three doors, a random permutation of the numbers 1, 2, and 3 would be generated, with each number representing a door. This permutation contains the first two numbers that correspond to the location of goats behind the door, and the third number corresponds to a car behind the door.
  • Using images, the configuration is represented graphically. Every configuration has its own image.
  • Only the door behind which there is a goat is to be revealed after the user has chosen a door number according to the puzzle. By selecting the door behind which the car is parked, the user can then reveal either of the other two doors. If the user selects a door behind which there is a goat, only one of the two remaining doors can be revealed (since the previously selected door cannot be revealed).

You can create sound from image files now. Imagine displaying an image from the forest with the actual forest sound in the background–Just adds to the drama. For this to run, have an image file and sound file (in .mp3 format) ready.

In this tutorial, we will learn how to use Optical Character Recognition (OCR) and Speech Synthesis, and then combine them into a single working program.

With one line of code, we can perform optical character recognition using the Python Library pytesseract.

Converting Generated Text to speech In Python, you can convert speech to text in a variety of ways. We will use Google Text to Speech to convert our decoded text into audio in this project.

gTTS(Google Text to Speech) As the following example shows, doing text-to-speech with one line of code is very simple.

With older Nokia phones, we had an old-age addiction with the snake game. But of course, we don’t have it anymore. What if you could write one for yourself using Python? Beginner Python programmers who are interested in making something easier in their domain can definitely try this out, and the module Turtle was built specifically for beginners to try and submit as part of the project. The project will be done in Python 3.

As a result, we will create a Python-based game using the following modules:

  • Turtle : It’s a pre-installed Python library that lets users create shapes and pictures using a virtual canvas.
  • Time : Use this function to count how many seconds have passed since the epoch.

Random : This function generates random numbers in Python by using the random module.

A GIF is an animated series of images that conveys an impression of movement. Would you like to create your own? Sure! Here is a Python project for creating GIFs. 

Let’s get started.

As famous as the gif market has become over these years now, demand for quality gifs is going up. The majority of people use these to communicate with others on social media platforms like WhatsApp, Instagram, etc. We will build a GIF Creator that creates GIFs from images here.

In this project, we will be using the MoviePy python module for development purposes. 

What is MoviePy?

MoviePy is a Python module that can be used to edit video (for example, to make cuts, concatenations, and title insertions), to do video compositing (also known as non-linear editing), or to do video processing. It is capable of reading and writing the most common video formats, including GIFs.

For installing MoviePy we can run the following command in our terminal:

Aren’t we all tired of random pop-ups during site surfing? So, we can create website blockers for restraining pushy ads by creating this Python project. A website blocker prevents access to websites permanently or on a schedule. We can block all websites from unwanted categories so that we can use the internet safely.

So, the Website Blocker Python project’s goal is to block websites from any device. By blocking websites from the user’s device, this project will help them stay away from distractions as they will not be able to open them.

This project enables the user to enter multiple websites to block, and then clicking on the block button will check whether the website has already been blocked, otherwise, block all those websites and print ‘blocked’.

Remember, when you code this, you can add the sites you need to block by editing sites_to_block, changing the host, or editing the time when you need to block the sites.

How do we do it?

A host file is part of every operating system. Operating systems may have different locations for the host file. It maps the hostname to the IP address of the machine. Here, we list the websites we want to block.

As the binary term explains, the system will take any input starting from 0 to any range that you specify and display a range of numbers with a difference of two.

We will be imitating a rolling dice as the program’s title suggests. This is one of the interesting python projects that generate a random number each time the program runs. The user can use the dice as often as he wants. The program will generate a random number between 1 and 6 when the user rolls the dice.

The user will then see the number. Additionally, the application asks users whether they would like to roll the dice again. Additionally, the program should be able to randomly pick a number between 1 and 6 and print it. 

Using a text-based user interface (TUI), you will be able to specify the number of six-sided dice you would like to roll with your dice-rolling simulator app.

Since we randomize the dice simulator outputs here, we’ll use the random module.

So, in this project, you will learn :

  • Simulating the rolling of dice by using random.randint()
  • Using methods such as .center() and .join() to manipulate strings
  • Using the built-in input() function to take the user’s input at the command line
  • how to parse and validate the user’s input

If you have little expertise with Python projects, you can directly start building these projects. These projects are for intermediate users who have some knowledge and wish to create more.

Want to create amazing stories from images? This project will let you produce a sentence after capturing the image. For this to work, download some pre-trained models and style vectors. Run:

Finally, we need the VGG-19 ConvNet parameters. You can obtain them by running:

Open config.py and specify the locations of all of the models and style vectors that you downloaded. For running on CPU, you will need to download the VGG-19 prototxt and model by:

Now, to generate a story, open Ipython and run:

A fun project to guess the number after getting a few hints from the computer. Every time a user gives a wrong answer, another hint pops up to make it easier for them.

What you will be doing in this project:

  • You can build a game where the user selects a range of numbers to guess.
  • Assume User selected a range, i.e., from A to B, where A and B belong to Integer.
  • The user has to guess an integer selected by the system within the minimum number of guesses

Here are the steps for building the project:

  • The user enters the lower and upper bounds of the range.
  • As a result, the compiler generates a random integer between the range and stores it in a variable for future use.
  • A while loop will be created for repetitive guessing.
  • When a user guesses a number that is greater than a randomly selected number, the user receives the message “Try Again!”. Your guess was too high.
  • If the user guesses a number smaller than a randomly selected number, the user gets an output of “Try Again!”.Your guess was too small”
  • In addition, if the user guesses within a minimum number of attempts, they get a “Congratulations!” message.
  • If the user fails to guess the integer in the minimum number of guesses, he/she will receive a “Better Luck Next Time!

In your coding journey, you must have come across the Fibonacci series which is a sequence of numbers in which each number is the sum of its two preceding numbers. 

A Fibonacci number sequence is defined mathematically by its recurrence relationship

Where F0=0 and F1=1

As the name suggests, in this project we will be creating a recursive function that takes input and checks whether the number belongs to the Fibonacci sequence or not.

Things to remember:

  • Ensure your data type is large enough to accommodate Fibonacci values
  • Make sure you use memoization by storing every value calculated at runtime when you use the top-down approach to recursion

Looking at the market majorly, we realise voice assistants are all up to take over our tasks. Siri, Alexa, and OkGoogle are already leading the market. How about you have a personal assistant of your own.

Python is, as we all know, an excellent language for scriptwriters and developers. Let’s create a script for Voice Assistant using Python. The assistant can be manipulated according to the user’s needs. 

Modules needed for this project:

Subprocesses :-Module for getting details of system subprocesses that are used by various commands such as shutdown, sleep, etc. Python includes this module by default. 

WolframAlpha :- Based on Wolfram’s algorithms, knowledgebase, and AI technology, WolframAlpha is used to compute expert-level answers. 

Pyttsx3 :- This module converts text to speech in a program and works offline. 

Tkinter :- This module is used for building GUI and comes inbuilt with Python.  

Wikipedia: – As we all know Wikipedia is a great source of knowledge just like IntervewBit. We use the Wikipedia module to access information from Wikipedia or to search Wikipedia. 

Speech Recognition :- In building an application for voice assistant, one of the most important things is that the assistant recognizes your voice (meaning what you want to ask). 

Web browser :- This built-in module is used for web search.

Ecapture :- This module is used for capturing images from your camera.

Pyjokes :- Pyjokes is a tool for collecting Python jokes online. 

Datetime :- Shows date and time

Twilio :- Twilio is used for making calls and sending messages.

Requests : Requests are used to make GET and POST requests. 

BeautifulSoup : The Beautiful Soup library allows you to easily scrape information from web pages.

The most difficult part of managing multiple accounts is generating a different strong password for each. A strong password is a mix of alphabets, numbers, and alphanumeric characters. Therefore, the best use of Python could be building a project where you could generate random passwords for any of your accounts.

In order to create a strong password, users can use this password generator to generate a random and customized password.

Steps required for building this project:

  • All characters should be stored as a list. This can be done with the string module of Python or by typing each character individually.
  • Ask the user for the length of the password.
  • Use random.shuffle to shuffle the characters.
  • Create an empty list to store the password.
  • Iterate length times to generate the password.
  • Choose a random character from all the characters using the random.choice method.
  • Add the random character to the password.
  • Randomize the resultant list of passwords.
  • Use the join method to create a string from the list of passwords.
  • Print the password.

We all have used Reddit for one purpose or the other. The famous question-answer app can now also have a bot linked to it. The bot will automate comments on the posts based on specified criteria.

For this to work :

  • Pick a subreddit to scan
  • Designate a specific comment to search for
  • Set your bot’s reply
  • Create a config.py file with your Reddit account details and Reddit.py file with the bot requirements
  • Pre-requisites: Python, Praw, and A reddit account

Creating the most famous card game of the casinos in Python would be a wonderful project. This game is played with a deck of 52 cards where the strategies play at best. Shuffle the cards, announce the buy-in amount, and decide the ranking of the cards. For ex. If Ace is given number 1 or 11. The player who gets the value of cards to 21 wins the game.

In case you need a quick refresher, here is how it works:

  • Bets are placed by players.
  • Players are dealt with 2 cards.
  • The dealer is dealt 2 cards, with the second one hidden from the players.
  • If you beat the dealer in this way, you win from the casino what you bet (you also win if the dealer busts). The goal is to have a higher point total than the dealer (but not more than 21). Each other card has a face value (face cards have a value of 10), except that aces have a value of either 1 or 11.
  • Blackjack refers to an initial 2 card hand composed of an ace and a face card. It is the best possible hand.
  • Immediately after the first round of dealing, each player has the option of hitting (receiving more cards) or staying (not receiving any more cards). The player loses his or her bet if hitting results in busting (going over 21).
  • After all the players have hit and stayed, the dealer flips over his hidden card. If the dealer’s total is less than 17, then he or she must hit (receive a new card). It repeats until either the dealer’s hand totals 17 or more, or the dealer busts (goes over 21).
  • After the dealer is done, the final results are decided – if the dealer busts, then any players who did not bust earlier will win their bet. As long as the dealer does not bust, each player’s total is compared to the dealer’s. If the player’s total exceeds the dealer’s, he or she wins money (in the amount of the bet). Any player whose total is less than the dealer’s loses. In the event of a tie, no money is exchanged.

This program creates a triangle using stars, recursively.

Implements queue data structure. A queue is an entity that maintains the data in a linear format and processes it in FIFO order.

In this project, you will be going to program a very fun python game. The goal of the rock-paper-scissor python project is to create a game that can be played from any computer, anywhere, and at any time.It is possible to indicate the move with a single alphabet or by entering an entire string

We will use the Tkinter and random module of Python to implement this python rock paper scissors game.

  • Tkinter is a standard GUI library that creates GUI apps easily.
  • The random module is used to generate random numbers.

Functions Used:

This program requires a number of functions, so let’s take a look at them all:

  • A Random function will be created for generating rock, paper, or scissors. 
  • A valid function will be created to check the validity of the move performed by the user.
  • A result function will be created to declare the winner of each round.
  • A scorekeeper to keep a track of the score in each round.

You can check the Source Code .

Python can be used to develop this simple GUI application. This project is about building a currency converter that will allow you to convert currencies from one unit to another, such as converting Indian rupee into pounds or euros.

The design of this application will be straightforward, focusing on the primary function, which is converting currency units. With Tkinter, you can access the Tk GUI toolkit, which comes with Python.

This currency converter project in python requires a basic understanding of python programming and the pygame library.

Tkinter – For UI requests – to get the URL

In your terminal, type the following code to install the Tkinter and requests libraries:

Here are the steps required for building the Python Project on Currency Converter:

  • Real-time Exchange rates: We will use: https://api.exchangerate-api.com/v4/latest/USD to get real-time exchange rates
  • Import required Libraries: Our Python project uses the Tkinter and requests libraries. We must import the libraries.
  • CurrencyConverter Class:Afterward, we will create a CurrencyConverter class that gathers real-time exchange rates, converts the currency, and returns the converted amount.
  • UI for CurrencyConverter: Next step will be to create a user interface for a currency converter.
  • Lastly create the main function.

    You can check Source Code

There are many things to learn in the world, and quizzes help in testing the understanding of those concepts. The Quiz Application will present questions to users and expect the users to respond accordingly. Think of it as a questionnaire.

Using the Quiz Application, it will be possible for special users, called administrators, to create tests, and then regular users can answer the questions and test their understanding.

  • This project consists of setting quizzes and asking people to answer them. Therefore, users should be able to ask questions, and other users should be able to answer them. The application will then display the final score and the correct answers.
  • Users should be able to create tests by uploading a text file with the questions and answers. You will be able to choose the format of the text file, so the application can convert the file into a quiz.
  • For this project, you will need to implement a database. Users’ questions, possible answers, correct answers, and scores will be stored in a database.

These Python projects are for all those developers who wish to explode the market with high-end applications for use.

Using Python and the popular Django framework, you’ll build a content aggregator from scratch.

Surfing through various websites to collate the best material for content is a tedious task. With this Python Project, searching and collating all the resources and materials in one place becomes a lot easier.

In this Project, you’ll learn:

  • RSS feeds: how to use them
  • How to create custom Django management commands
  • How to run your custom command when you specify a schedule
  • Testing your Django app’s functionality with unit tests

The major steps involved in this project are:

  • Create a list of sites from which you want to collect data.
  • Scrape these sites’ content using libraries like HTTP request sender and BeautifulSoup.
  • Apscheduler is used for background content management.
  • Scrapped content is stored in a database.

A chatbot is a software application based on artificial intelligence that interacts with humans in their own natural language.

Every site that we open nowadays has a chatbot integrated to extract information from the user/visitor in real-time. This way the problem of manually looking out for customers is solved. Now, you can even create chatbots that talk to the user and grab information. This AI provides numerous features like learning, memory, conditional switch, topic-based conversation handling, etc.

For building a chatbot ,

You must import all the necessary packages and initialize the variables. If you work with text data, remember to perform data preprocessing on your dataset before designing an ML model.

In this situation, tokenizing helps to fragment large text datasets into small, readable chunks (like words). Afterwards, you can also lemmatize a word, which transforms it into its lemma form. Afterwards, it creates a pickle file to store the Python objects used to predict the bot’s responses. 

A crucial part of the chatbot development process is creating the training and testing datasets. 

With the current pandemic times, a face mask is highly appreciated wherever we go. But it also becomes tiresome to manually detect people without a mask. This Python Project lets you detect a mask and prompt any error. This can be applied in malls or any public meeting place. 

What we will be doing in this project:

  •  Using Python, Keras, and OpenCV, we will develop a deep-learning model for face mask detection. 
  • We will develop a face mask detector model to detect whether a person is wearing a mask or not. 
  • Keras-based network architecture is used to train the model. 
  • First, the model is trained, and then the OpenCV program is used to test the model using a webcam.

Introduction to Image Processing

We need to understand how to handle images before implementing the face mask detection problem. An image is simply a collection of colors in red, green, and blue. As humans, we see images with objects and shapes in them, but a computer sees them as color arrays with values ranging from 0 to 255.

Computers perceive images differently from humans. But that’s the good news for us because if we get an array of the image, then it becomes a lot easier to implement any algorithm on the array.

Steps to Perform Image Processing :

  • Use Python or any other programming language you are using to load images.
  • Convert the images into an array.
  • And finally, apply some algorithms.

It is also good that we have a library called OpenCV that will allow us to read the image and return an array of colour pixels.

For the source code, you can refer to the Github link .

A nightmare for a writer is whether or not the written work falls into plagiarism barriers. The plagiarism tool scans through your work to find an overlap from an existing source posted online. 

To avoid any overlap for stealing someone’s work, we tend to put our work through plagiarism checkers. But the tools cost a fortune. So, with this Python project, you can create a plagiarism checker to scour through any writing work. This Python project uses a Natural Language Processing tool along with a search API to prepare a full-fledged usable Plagiarism checker. 

What you will need:

  • TensorFlow is an extremely powerful library for building neural networks with a variety of parameters. A neural network consists of an input layer, hidden layers, and an output layer.
  • We will also need Natural Language Toolkit (NLTK) to prepare the dataset with our own texts for training the machine learning model. We must tokenize the root words from texts in order to train the machine learning model. 

Input will be a CSV file with only one ‘Text’ column. The file is named InterviewBit.csv. The text in each row of the column ‘Text’ will be different. You can make these texts as long as you want, as long as they do not contain commas or special symbols. For longer texts, the model will require more epochs to provide higher accuracy.  

You will be learning the following things while building this project:

  • the basic knowledge of neural networks
  •  stemming words
  •  Tokenization
  •  natural language processing

Almost everyone loves to listen to music. Imagine, creating a music player of your own that involves scanning through project files to find music files, browsing through various tracks, adding music from your favourite artists, or controlling the volume. 

With this Python project, you create a full-fledged music player with an interactive UI to play around with.

To be able to build this project you should have Tkinter and pygame installed on your device.

  • We will use Tkinter to render our application’s menu and its buttons, as well as to load the music from files, and then to play, pause, and stop it using pygame library. Also, Tkinter is a lightweight module and can be used to create cross-platform applications (the same code will work on Windows, macOS, and Linux).
  • In Python, Pygame provides an inbuilt method called mixer () which allows us to deal with sound files easily, i.e:
  •   loading and playing music
  •    pausing and unpausing music
  •    stopping the music file

Functions Used

  • playsong : The active song is loaded from the list and played. When the user clicks “play”, the song is played.
  • pausesong : If the user clicks “pausesong”, the song is paused. It is executed when the user clicks “pause”.
  • stopsong: It stops the song. After clicking “stop”, it is executed.
  • resumesong: It is used for resuming the required song. When the user clicks “resume” it is executed.

The real value of whatever you learn comes with APPLICATION. Application of your learnings and processes. Building Python projects:

  • Build confidence: You realize how comfortable you’ve become with the language. This allows you to try on new features without any hesitation. 
  • Concepts: Your programming concepts become solid and you tend to write more maintainable codes. With this, you learn to create better design patterns, integrate OOPS concerts, and avoid repeating yourself in the codes. 
  • Product Lifecycle: By building projects yourself, you involve yourself in the nitty-gritty stuff of the entire lifecycle. You get involved with–Planning, managing, and updating the code. Also keeping the clients’ requests on top. 
  • Broader Scope: By building projects using Python, you not only build daily stuff easily but get access to fields like data science, web development, machine learning, and many more. 
  • Community Building: You build your own community, create open-source projects, and create a name for yourself.

Ans. Python is suitable for any kind of project, especially long-form projects. To handle a large project, you need loose coupling and high cohesion. A large project essentially needs an orthogonal structure to carry out small sub-projects as well. Its speed is relatively high to handle all the mathematical functions. And Python can indeed be a great language to handle every such demand, efficiently.  For example, pydev provides auto-completion and debugging support for python with all the other eclipse goodies like svn support.

Ans. For writing a project in Python, 

  • Choose any tool like Pycharm and follow the steps.

Ans. Start from any of the beginner-level Python projects that are mentioned above. Once you get a handle on Python with those simple projects like creating–MadLibs Generator, Rock-Paper-Scissors, or Website blocker, you can move on to create other projects. If you need to brush up on your Python concepts, you can check out this free course in Python for beginners.

Ans. Maybe. Python is used to create large projects but not large monolithic projects because it is dynamically typed. In large monolithic projects, it is difficult to keep a track of all the data types. So, it’s better to design the system as smaller components combined together with better functionality and interface. 

Ans. Creating a project on Python is highly dependent on your own interests as an individual. Find your interests and see projects overlapping with those interests. Try creating using those libraries and code structures.

Ans. Python code after coding is converted into bytecode, internally. To convert that code into a readable format, we need an interpreter called the Python Virtual Machine:

  • A syntax checker runs on the code.
  • Code is internally compiled
  • The bytecode is interpreted using PVM
  • Finally, the output is generated. 

The steps involved to run a Python Project are:

  • Open a CMD prompt. Press CMD+R (For windows) and press ENTER.
  • Navigate to the folder (C:\….) on your local folder and find the .py file.
  • And type python filename.py
  • Learn Python
  • Python Developer Salary
  • How to Become a Python Developer
  • Python Interview Questions
  • Features of Python
  • Difference Between Python 2 and 3
  • Python Frameworks
  • Python Books
  • Python Developer Resume
  • Applications of Python
  • Python Developer Skills
  • Python Libraries
  • Python vs Java
  • Python Projects

Previous Post

Top 15 android project ideas (with source code), top 15 java projects with source code [2023].

  • Subscription

Python Practice: 93 Unique Online Coding Exercises

Whether you're just starting your learning journey or looking to brush up before a job interview, getting the right kind of Python practice can make a big difference.

Research shows that hands-on practice is the most effective way to learn, * and luckily there are so many different ways to practice that you're bound to find one that works best for you.

In this post, we'll share 93 ways to practice Python online by writing actual code, broken down into different practice methods.

Table of Contents

Core python programming (great for beginners), intermediate python programming, data handling and manipulation with numpy, data handling and manipulation with pandas, data analysis, complexity and algorithms, python introduction (great for beginners), data analysis and visualization, data cleaning.

  • Machine Learning

AI and Deep Learning

Probability and statistics, beginner projects, data analysis projects, data engineering projects, machine learning and ai projects, core python concepts (great for beginners), intermediate techniques, data analysis and data science, frequently asked questions, where can i practice python programming.

  • How can I practice Python programming?

Can I learn Python in 30 days?

Can i practice python on mobile, how quickly can i learn python, ai is advancing so quickly - should i still learn python, practice with free python coding exercises.

Exercises are a great way to practice a specific topic with targeted efficiency. For example, do you have an upcoming job interview where you know you'll be asked about Python dictionaries? Completing exercises about dictionaries will help refresh your skills and ensure you can confidently speak to this Pythonic datatype.

  • Basic Mathematical Operators (free) — Use Python to perform calculations and printing results to the screen.
  • Variables and data types (free) — Work with variables and doing calculations with variables.
  • Lists and loops (free) — Practice using Python lists and for loops.
  • Dictionaries 1 (free) — Use dictionaries in Python.
  • Dictionaries 2 (free) — More practice with dictionaries and frequency tables.
  • Lists (free) — Practice using lists in Python.
  • Conditional statements (if-else) — Use conditional statements in Python.
  • Sets — Practice using sets in Python.
  • Python functions — Define and call functions.
  • Intermediate Python functions — Practice more advanced usage of functions like returning multiple values.
  • Object oriented programming (OOP) — Define classes, methods, and attributes.
  • NumPy index selection (free) — Select values from ndarrays.
  • NumPy creating ndarrays — Create ndarrays with specific values and shapes.
  • NumPy ndarray methods — Use ndarray methods to perform calculations.
  • NumPy broadcasting — Work with ndarrays with different shapes and using broadcasting to create ndarrays.
  • NumPy boolean masks — Select data from ndarrays use boolean masks
  • NumPy datatypes — Work with NumPy datatypes
  • NumPy sorting — Practice sorting ndarrays
  • NumPy stacking and splitting — Stack and split ndarrays
  • Pandas series (free) — Use and build pandas series.
  • Creating and manipulating dataframes — Create and manipulate pandas dataframes.
  • Selecting data with Pandas — Select data from dataframes.
  • Loading and exploring data — Load data into dataframes and explore it.
  • Pandas boolean masks — Use boolean masks to select data from dataframes.
  • Pandas Data Cleaning — Clean data in a dataframe.
  • Cleaning and preparing data (free) — Write functions to remove incorrect characters and fill missing values.
  • Data analysis basics — Manipulate data from CSV files using Python dictionaries and functions.
  • Working with dates and times — Practice with the datetime module in Python.
  • Time complexity of algorithms (free) — Identify the type of time complexity of Python functions.
  • Constant time complexity — Find the constant time complexity of functions.
  • Logarithmic complexity — Practice finding the logarithmic time complexity of functions.
  • Sorting algorithms — Create and work with sorting algorithms in Python.
  • Space complexity — Practice space complexity by writing Python functions.

Explore our full library of Python practice problems to continue improving your skills.

Practice with Online Python Courses

If you're looking for more structure, then practicing with Python courses online may resonate with you. Courses guide you through a topic, so if you want to gain a new skill or you're rusty on an old one, completing a course is an excellent way to go.

Throughout these courses, you'll be given questions and assignments to test your skills. Additionally, some of these courses contain a guided project that allows you to apply everything you've learned.

See below for some recommended courses.

  • Introduction to Python — Write code using Python syntax; work with different types of data; and perform basic Python operations such as working with variables, processing numerical and text data, and manipulating lists.
  • Basic Operators and Data Structures in Python — Learn the fundamentals of Python for loops, dictionaries, and conditional logic (if-else).
  • Python Functions and Jupyter Notebook — Write Python functions, build functions that employ multiple return statements and return multiple variables, and install and use Jupyter Notebook.
  • Python for Data Science: Intermediate — Manipulate text, clean messy data, work with object-oriented programming concepts, and use dates and times in Python.
  • Pandas and NumPy Fundamentals — Use NumPy and pandas for data exploration, preparation, and analysis.
  • Data Visualization Fundamentals — Balance graph creation and statistics in your visualizations using tools such as Matplotlib and Seaborn.
  • Storytelling Data Visualization and Information Design — Use information design and data visualization to tell compelling stories.
  • Data Cleaning and Analysis — Manipulate, combine, transform, and merge data; manipulate strings; and work with missing values in Python.
  • Data Cleaning in Python: Advanced — Clean and manipulate text data using basic and advanced regular expressions, how to resolve missing data, and how to employ lambda functions and list comprehension with pandas.
  • Data Cleaning Project Walkthrough — Combine multiple datasets and prepare them for analysis.
  • Intro to Supervised Machine Learning — Build a supervised machine learning model in Python, and train and improve it for better performance and accuracy.
  • Intro to Unsupervised Machine Learning — Learn about unsupervised machine learning models in Python, when to apply them, and what differentiates them from supervised machine learning models.
  • Linear Regression Modeling — Build, evaluate, and interpret the results of a linear regression model, as well as using linear regression models for inference and prediction.
  • Gradient Descent Modeling — Learn the fundamentals of gradient descent and how to implement this algorithm in Python.
  • Logistic Regression Modeling — Build and evaluate logistic regression models, both from scratch and using scikit-learn.
  • Decision Tree and Random Forest Modeling — Learn the foundations of Decision Trees including identifying the key components of trees, interpreting them, classifying new observations using decision trees and calculating optimal thresholds for both classification and regression trees.
  • Optimizing Machine Learning Models — Explore the most common methods and techniques that will enable you to optimize your machine learning models for better efficiency.
  • APIs for AI Applications — Use Python for retrieving, analyzing, and manipulating real-world data from various sources including the World Development Indicators database.
  • Prompting Large Language Models (LLMs) — Create an AI-powered chatbot using Python, that incorporates key concepts like prompt engineering, managing conversation histories, and efficiently regulating token usage within an AI framework.
  • Intro to Deep Learning in Tensorflow — Learn the fundamentals of deep learning, as well as how to build, train, and evaluate models using the TensorFlow framework.
  • Introduction to Statistics in Python — Work with techniques for sampling data, concepts such as discrete variables and random variables, and the different types of charts and graphs you might use to visualize frequency distributions.
  • Intermediate Statistics in Python — Summarize distributions using mean, median, and mode. You’ll also learn to measure variability using variance or standard deviation and how to locate and compare values using z-scores.
  • Introduction to Probability in Python — Estimate probabilities, work with the addition and multiplication rules, and define permutations and combinations.
  • Introduction to Conditional Probability in Python — Assign probabilities to events based on certain conditions, evaluate whether they are in a relationship of statistical independence or not, and on prior knowledge by using Bayes’s theorem.
  • Hypothesis Testing in Python — Learn advanced statistical concepts like significance testing and multi-category chi-square testing,

These courses are a great way to practice Python online, and they're all free to start. If you're looking for more courses, you can find them on Dataquest's course page .

Practice with Python Projects

One of the most effective ways to practice Python online is with projects. When I was learning Python, it was easy to forget newly acquired skills. When I discovered that I could do projects to practice my newfound knowledge, it helped me remember new syntax. Additionally, I built a great portfolio of work to show potential employers.

Here are a few projects you can use to start practicing right now.

  • Profitable App Profiles for the App Store and Google Play Markets (free) — Assume the role of a data analyst at a company that builds apps for Android and iOS. Since the company’s revenue depends on in-app ads, your task is analyzing historical data from app markets to determine which apps attract the most users.
  • Learn and Install Jupyter Notebook (free) — Run Python code in a Jupyter Notebook and learn how to install Jupyter locally.
  • Build a Word Guessing Game (free) — Have some fun, and create a functional and interactive word-guessing game using Python.
  • Build a Garden Simulator Text Based Game (free) — Create an interactive text-based “Garden Simulator” using object-oriented programming, error handling, and randomness.
  • Build a Food Ordering App — Create a functional and interactive food ordering application using Python.
  • Investigating Fandango Movie Ratings (free) — Step into the role of a data journalist to analyze movie ratings data and determine if there’s evidence of bias in Fandango’s rating system.
  • Exploring Hacker News Posts (free) — Analyze a dataset from Hacker News and apply your Python skills in string handling, object-oriented programming, and data management to uncover trends in user submissions.
  • Exploring eBay Car Sales Data — Use Python to work with a scraped dataset of used cars from eBay Kleinanzeigen, a classifieds section of the German eBay website.
  • Finding Heavy Traffic Indicators on I-94 — Explore how using the pandas plotting functionality along with the Jupyter Notebook interface allows us to explore data quickly using visualizations.
  • Storytelling Data Visualization on Exchange Rates — Quickly create multiple subsetted plots using one or more conditions.
  • Clean and Analyze Employee Exit Surveys — Work with exit surveys from employees of the Department of Education in Queensland, Australia. Play the role of a data analyst and pretend the stakeholders want answers to important data questions.
  • Analyzing NYC High School Data — Discover the SAT performance of different demographics using scatter plots and maps.
  • Building Fast Queries on a CSV (free) — Act as a Python developer to build an inventory system for a laptop store. You’ll apply efficient data structures and algorithms to enable fast queries.
  • Analyzing Wikipedia Pages (free) — Process over 54 MB of Wikipedia articles to find specific text matches. Using Python and MapReduce, you’ll build a parallel solution to search the dataset and return match details efficiently.
  • Building a database for crime reports — Use PostgreSQL to build a database with proper schemas, tables, and user roles to store and manage crime report data efficiently.
  • Predicting Heart Disease (free) — Act as a data scientist at a healthcare solutions company to build a model that predicts a patient’s risk of developing heart disease based on their medical data.
  • Predicting Insurance Costs — Use linear regession modeling to predict insurance costs.
  • Developing a Dynamic AI Chatbot — Create an AI chatbot that can take on different personas and keep track of conversation history.

If these didn't spark your interest, here are plenty of other online Python projects you can try.

Practice with Online Python Tutorials

If online practice exercises, courses, and projects don't appeal to you, here are a few blog-style tutorials to help you learn Python. I like to use this type of resource when I'm on my phone to get some productive reading done, even when I can't code on my computer!

  • Python strings — See how to declare the string data type, the relationship between the string data type and the ASCII table, the properties of the string data type, and some important string methods and operations.
  • Python dictionaries — Learn how to create a Python dictionary, how to use its methods, and dictionary comprehension.
  • Python data structures — Read about what data structures exist in Python, when to apply them, and their pros and cons.
  • Python classes — Learn how to create and work with Python classes. See what Python classes are, why we use them, what types of classes exist, how to define a class in Python and declare/adjust class objects,
  • Python lists — Read how to define, create, and slice lists, as well as how to add/remove items and use a for loop to iterate over a list.
  • If statements — Use conditional logic with if, elif, and else to streamline your code's efficiency.
  • Python datetime — Learn the uses of the datetime module, extract dates, and work with timestamps.
  • Python ternary — Understand what a Python ternary operator is and when it's useful.
  • Python subprocess — See how to use the subprocess module in Python to run different subprocesses during the course of a regular python script.
  • Python math module — Read about the common constants and functions implemented in the math module — and how to use them.
  • Read files in Python — Learn how to open files, use the with context manager, read text, CSV, and JSON files, and understand different file modes.
  • Lambda functions — Define lambda functions in Python and explore the advantages and limitations of employing them.
  • Reset index in pandas — Discusses the reset_index() pandas method, why we may need to reset the index of a DataFrame in pandas, and how we can apply and tune this method.
  • GroupBy in pandas — Explore how to create a GroupBy object in pandas library of Python and how this object works.
  • Getting Started with APIs — Understand how to retrieve data for AI and data science projects using APIs (Application Programming Interfaces).
  • Introduction to Keras — Learn how to install and start using Keras; the Sequential API; and the steps for building, compiling, and training a model..
  • Implement Support Vector Machines (SVMs) — Read about support vector machines, one of the most popular classification algorithms. Learn how to implement SVMs for a classification task in Python.

The web is also full of thousands of other beginner Python tutorials. As long as you've got a solid foundation in the Python basics, you can find great practice through many of them.

Dataquest.io has dozens of free interactive practice questions, as well as free interactive lessons, project ideas and walkthroughs, tutorials, and more.

HackerRank is a great site for practice that’s also interactive.

CodingGame is a fun platform for practice that supports Python.

Edabit has Python challenges that can be good for practicing or self-testing.

You can also practice Python using all of the interactive lessons listed above

How can I practice Python at home?

Install Python on your machine. You can download it directly here , or download a program like Anaconda Individual Edition that makes the process easier. Or you can find an interactive online platform like Dataquest and write code in your browser without installing anything.

Find a good Python project or some practice problems to work on.

Make detailed plans. Scheduling your practice sessions will make you more likely to follow through.

Join an online community. It's always great to get help from a real person. Reddit has great Python communities, and Dataquest's community is great if you're learning Python data skills.

In 30 days, you can definitely learn enough Python to be able to build some cool things. You won't be able to master Python that quickly, but you could learn to complete a specific project or do things like automate some aspects of your job.

Read more about how long it takes to learn Python .

Yes, there are many apps that allow you to practice Python on both iOS and Android. However, this shouldn't be your primary form of practice if you aspire to use Python in your career— it's good to practice installing and working with Python on desktops and laptops since that's how most professional programming work is done.

You can learn the fundamentals of Python in a weekend. If you're diligent, you can learn enough to complete small projects and genuinely impact your work within a month or so. Mastering Python takes much longer, but you don't need to become a master to get things done!

Absolutely, Python remains essential in the AI field. It's foundational for developing AI technologies and continuously updated to integrate with the latest AI advancements. Python libraries like TensorFlow and Keras facilitate efficient building and training of complex AI models. Learning Python also ensures you understand the underlying mechanisms of AI tools, making you a more proficient developer.

More learning resources

Tutorial: how to easily read files in python (text, csv, json), grouping data: a step-by-step tutorial to groupby in pandas.

Learn data skills 10x faster

Headshot

Join 1M+ learners

Enroll for free

  • Data Analyst (Python)
  • Gen AI (Python)
  • Business Analyst (Power BI)
  • Business Analyst (Tableau)
  • Data Analyst (R)

Python's Assignment Operator: Write Robust Assignments

Python's Assignment Operator: Write Robust Assignments

Table of Contents

The Assignment Statement Syntax

The assignment operator, assignments and variables, other assignment syntax, initializing and updating variables, making multiple variables refer to the same object, updating lists through indices and slices, adding and updating dictionary keys, doing parallel assignments, unpacking iterables, providing default argument values, augmented mathematical assignment operators, augmented assignments for concatenation and repetition, augmented bitwise assignment operators, annotated assignment statements, assignment expressions with the walrus operator, managed attribute assignments, define or call a function, work with classes, import modules and objects, use a decorator, access the control variable in a for loop or a comprehension, use the as keyword, access the _ special variable in an interactive session, built-in objects, named constants.

Python’s assignment operators allow you to define assignment statements . This type of statement lets you create, initialize, and update variables throughout your code. Variables are a fundamental cornerstone in every piece of code, and assignment statements give you complete control over variable creation and mutation.

Learning about the Python assignment operator and its use for writing assignment statements will arm you with powerful tools for writing better and more robust Python code.

In this tutorial, you’ll:

  • Use Python’s assignment operator to write assignment statements
  • Take advantage of augmented assignments in Python
  • Explore assignment variants, like assignment expressions and managed attributes
  • Become aware of illegal and dangerous assignments in Python

You’ll dive deep into Python’s assignment statements. To get the most out of this tutorial, you should be comfortable with several basic topics, including variables , built-in data types , comprehensions , functions , and Python keywords . Before diving into some of the later sections, you should also be familiar with intermediate topics, such as object-oriented programming , constants , imports , type hints , properties , descriptors , and decorators .

Free Source Code: Click here to download the free assignment operator source code that you’ll use to write assignment statements that allow you to create, initialize, and update variables in your code.

Assignment Statements and the Assignment Operator

One of the most powerful programming language features is the ability to create, access, and mutate variables . In Python, a variable is a name that refers to a concrete value or object, allowing you to reuse that value or object throughout your code.

To create a new variable or to update the value of an existing one in Python, you’ll use an assignment statement . This statement has the following three components:

  • A left operand, which must be a variable
  • The assignment operator ( = )
  • A right operand, which can be a concrete value , an object , or an expression

Here’s how an assignment statement will generally look in Python:

Here, variable represents a generic Python variable, while expression represents any Python object that you can provide as a concrete value—also known as a literal —or an expression that evaluates to a value.

To execute an assignment statement like the above, Python runs the following steps:

  • Evaluate the right-hand expression to produce a concrete value or object . This value will live at a specific memory address in your computer.
  • Store the object’s memory address in the left-hand variable . This step creates a new variable if the current one doesn’t already exist or updates the value of an existing variable.

The second step shows that variables work differently in Python than in other programming languages. In Python, variables aren’t containers for objects. Python variables point to a value or object through its memory address. They store memory addresses rather than objects.

This behavior difference directly impacts how data moves around in Python, which is always by reference . In most cases, this difference is irrelevant in your day-to-day coding, but it’s still good to know.

The central component of an assignment statement is the assignment operator . This operator is represented by the = symbol, which separates two operands:

  • A value or an expression that evaluates to a concrete value

Operators are special symbols that perform mathematical , logical , and bitwise operations in a programming language. The objects (or object) on which an operator operates are called operands .

Unary operators, like the not Boolean operator, operate on a single object or operand, while binary operators act on two. That means the assignment operator is a binary operator.

Note: Like C , Python uses == for equality comparisons and = for assignments. Unlike C, Python doesn’t allow you to accidentally use the assignment operator ( = ) in an equality comparison.

Equality is a symmetrical relationship, and assignment is not. For example, the expression a == 42 is equivalent to 42 == a . In contrast, the statement a = 42 is correct and legal, while 42 = a isn’t allowed. You’ll learn more about illegal assignments later on.

The right-hand operand in an assignment statement can be any Python object, such as a number , list , string , dictionary , or even a user-defined object. It can also be an expression. In the end, expressions always evaluate to concrete objects, which is their return value.

Here are a few examples of assignments in Python:

The first two sample assignments in this code snippet use concrete values, also known as literals , to create and initialize number and greeting . The third example assigns the result of a math expression to the total variable, while the last example uses a Boolean expression.

Note: You can use the built-in id() function to inspect the memory address stored in a given variable.

Here’s a short example of how this function works:

The number in your output represents the memory address stored in number . Through this address, Python can access the content of number , which is the integer 42 in this example.

If you run this code on your computer, then you’ll get a different memory address because this value varies from execution to execution and computer to computer.

Unlike expressions, assignment statements don’t have a return value because their purpose is to make the association between the variable and its value. That’s why the Python interpreter doesn’t issue any output in the above examples.

Now that you know the basics of how to write an assignment statement, it’s time to tackle why you would want to use one.

The assignment statement is the explicit way for you to associate a name with an object in Python. You can use this statement for two main purposes:

  • Creating and initializing new variables
  • Updating the values of existing variables

When you use a variable name as the left operand in an assignment statement for the first time, you’re creating a new variable. At the same time, you’re initializing the variable to point to the value of the right operand.

On the other hand, when you use an existing variable in a new assignment, you’re updating or mutating the variable’s value. Strictly speaking, every new assignment will make the variable refer to a new value and stop referring to the old one. Python will garbage-collect all the values that are no longer referenced by any existing variable.

Assignment statements not only assign a value to a variable but also determine the data type of the variable at hand. This additional behavior is another important detail to consider in this kind of statement.

Because Python is a dynamically typed language, successive assignments to a given variable can change the variable’s data type. Changing the data type of a variable during a program’s execution is considered bad practice and highly discouraged. It can lead to subtle bugs that can be difficult to track down.

Unlike in math equations, in Python assignments, the left operand must be a variable rather than an expression or a value. For example, the following construct is illegal, and Python flags it as invalid syntax:

In this example, you have expressions on both sides of the = sign, and this isn’t allowed in Python code. The error message suggests that you may be confusing the equality operator with the assignment one, but that’s not the case. You’re really running an invalid assignment.

To correct this construct and convert it into a valid assignment, you’ll have to do something like the following:

In this code snippet, you first import the sqrt() function from the math module. Then you isolate the hypotenuse variable in the original equation by using the sqrt() function. Now your code works correctly.

Now you know what kind of syntax is invalid. But don’t get the idea that assignment statements are rigid and inflexible. In fact, they offer lots of room for customization, as you’ll learn next.

Python’s assignment statements are pretty flexible and versatile. You can write them in several ways, depending on your specific needs and preferences. Here’s a quick summary of the main ways to write assignments in Python:

Up to this point, you’ve mostly learned about the base assignment syntax in the above code snippet. In the following sections, you’ll learn about multiple, parallel, and augmented assignments. You’ll also learn about assignments with iterable unpacking.

Read on to see the assignment statements in action!

Assignment Statements in Action

You’ll find and use assignment statements everywhere in your Python code. They’re a fundamental part of the language, providing an explicit way to create, initialize, and mutate variables.

You can use assignment statements with plain names, like number or counter . You can also use assignments in more complicated scenarios, such as with:

  • Qualified attribute names , like user.name
  • Indices and slices of mutable sequences, like a_list[i] and a_list[i:j]
  • Dictionary keys , like a_dict[key]

This list isn’t exhaustive. However, it gives you some idea of how flexible these statements are. You can even assign multiple values to an equal number of variables in a single line, commonly known as parallel assignment . Additionally, you can simultaneously assign the values in an iterable to a comma-separated group of variables in what’s known as an iterable unpacking operation.

In the following sections, you’ll dive deeper into all these topics and a few other exciting things that you can do with assignment statements in Python.

The most elementary use case of an assignment statement is to create a new variable and initialize it using a particular value or expression:

All these statements create new variables, assigning them initial values or expressions. For an initial value, you should always use the most sensible and least surprising value that you can think of. For example, initializing a counter to something different from 0 may be confusing and unexpected because counters almost always start having counted no objects.

Updating a variable’s current value or state is another common use case of assignment statements. In Python, assigning a new value to an existing variable doesn’t modify the variable’s current value. Instead, it causes the variable to refer to a different value. The previous value will be garbage-collected if no other variable refers to it.

Consider the following examples:

These examples run two consecutive assignments on the same variable. The first one assigns the string "Hello, World!" to a new variable named greeting .

The second assignment updates the value of greeting by reassigning it the "Hi, Pythonistas!" string. In this example, the original value of greeting —the "Hello, World!" string— is lost and garbage-collected. From this point on, you can’t access the old "Hello, World!" string.

Even though running multiple assignments on the same variable during a program’s execution is common practice, you should use this feature with caution. Changing the value of a variable can make your code difficult to read, understand, and debug. To comprehend the code fully, you’ll have to remember all the places where the variable was changed and the sequential order of those changes.

Because assignments also define the data type of their target variables, it’s also possible for your code to accidentally change the type of a given variable at runtime. A change like this can lead to breaking errors, like AttributeError exceptions. Remember that strings don’t have the same methods and attributes as lists or dictionaries, for example.

In Python, you can make several variables reference the same object in a multiple-assignment line. This can be useful when you want to initialize several similar variables using the same initial value:

In this example, you chain two assignment operators in a single line. This way, your two variables refer to the same initial value of 0 . Note how both variables hold the same memory address, so they point to the same instance of 0 .

When it comes to integer variables, Python exhibits a curious behavior. It provides a numeric interval where multiple assignments behave the same as independent assignments. Consider the following examples:

To create n and m , you use independent assignments. Therefore, they should point to different instances of the number 42 . However, both variables hold the same object, which you confirm by comparing their corresponding memory addresses.

Now check what happens when you use a greater initial value:

Now n and m hold different memory addresses, which means they point to different instances of the integer number 300 . In contrast, when you use multiple assignments, both variables refer to the same object. This tiny difference can save you small bits of memory if you frequently initialize integer variables in your code.

The implicit behavior of making independent assignments point to the same integer number is actually an optimization called interning . It consists of globally caching the most commonly used integer values in day-to-day programming.

Under the hood, Python defines a numeric interval in which interning takes place. That’s the interning interval for integer numbers. You can determine this interval using a small script like the following:

This script helps you determine the interning interval by comparing integer numbers from -10 to 500 . If you run the script from your command line, then you’ll get an output like the following:

This output means that if you use a single number between -5 and 256 to initialize several variables in independent statements, then all these variables will point to the same object, which will help you save small bits of memory in your code.

In contrast, if you use a number that falls outside of the interning interval, then your variables will point to different objects instead. Each of these objects will occupy a different memory spot.

You can use the assignment operator to mutate the value stored at a given index in a Python list. The operator also works with list slices . The syntax to write these types of assignment statements is the following:

In the first construct, expression can return any Python object, including another list. In the second construct, expression must return a series of values as a list, tuple, or any other sequence. You’ll get a TypeError if expression returns a single value.

Note: When creating slice objects, you can use up to three arguments. These arguments are start , stop , and step . They define the number that starts the slice, the number at which the slicing must stop retrieving values, and the step between values.

Here’s an example of updating an individual value in a list:

In this example, you update the value at index 2 using an assignment statement. The original number at that index was 7 , and after the assignment, the number is 3 .

Note: Using indices and the assignment operator to update a value in a tuple or a character in a string isn’t possible because tuples and strings are immutable data types in Python.

Their immutability means that you can’t change their items in place :

You can’t use the assignment operator to change individual items in tuples or strings. These data types are immutable and don’t support item assignments.

It’s important to note that you can’t add new values to a list by using indices that don’t exist in the target list:

In this example, you try to add a new value to the end of numbers by using an index that doesn’t exist. This assignment isn’t allowed because there’s no way to guarantee that new indices will be consecutive. If you ever want to add a single value to the end of a list, then use the .append() method.

If you want to update several consecutive values in a list, then you can use slicing and an assignment statement:

In the first example, you update the letters between indices 1 and 3 without including the letter at 3 . The second example updates the letters from index 3 until the end of the list. Note that this slicing appends a new value to the list because the target slice is shorter than the assigned values.

Also note that the new values were provided through a tuple, which means that this type of assignment allows you to use other types of sequences to update your target list.

The third example updates a single value using a slice where both indices are equal. In this example, the assignment inserts a new item into your target list.

In the final example, you use a step of 2 to replace alternating letters with their lowercase counterparts. This slicing starts at index 1 and runs through the whole list, stepping by two items each time.

Updating the value of an existing key or adding new key-value pairs to a dictionary is another common use case of assignment statements. To do these operations, you can use the following syntax:

The first construct helps you update the current value of an existing key, while the second construct allows you to add a new key-value pair to the dictionary.

For example, to update an existing key, you can do something like this:

In this example, you update the current inventory of oranges in your store using an assignment. The left operand is the existing dictionary key, and the right operand is the desired new value.

While you can’t add new values to a list by assignment, dictionaries do allow you to add new key-value pairs using the assignment operator. In the example below, you add a lemon key to inventory :

In this example, you successfully add a new key-value pair to your inventory with 100 units. This addition is possible because dictionaries don’t have consecutive indices but unique keys, which are safe to add by assignment.

The assignment statement does more than assign the result of a single expression to a single variable. It can also cope nicely with assigning multiple values to multiple variables simultaneously in what’s known as a parallel assignment .

Here’s the general syntax for parallel assignments in Python:

Note that the left side of the statement can be either a tuple or a list of variables. Remember that to create a tuple, you just need a series of comma-separated elements. In this case, these elements must be variables.

The right side of the statement must be a sequence or iterable of values or expressions. In any case, the number of elements in the right operand must match the number of variables on the left. Otherwise, you’ll get a ValueError exception.

In the following example, you compute the two solutions of a quadratic equation using a parallel assignment:

In this example, you first import sqrt() from the math module. Then you initialize the equation’s coefficients in a parallel assignment.

The equation’s solution is computed in another parallel assignment. The left operand contains a tuple of two variables, x1 and x2 . The right operand consists of a tuple of expressions that compute the solutions for the equation. Note how each result is assigned to each variable by position.

A classical use case of parallel assignment is to swap values between variables:

The highlighted line does the magic and swaps the values of previous_value and next_value at the same time. Note that in a programming language that doesn’t support this kind of assignment, you’d have to use a temporary variable to produce the same effect:

In this example, instead of using parallel assignment to swap values between variables, you use a new variable to temporarily store the value of previous_value to avoid losing its reference.

For a concrete example of when you’d need to swap values between variables, say you’re learning how to implement the bubble sort algorithm , and you come up with the following function:

In the highlighted line, you use a parallel assignment to swap values in place if the current value is less than the next value in the input list. To dive deeper into the bubble sort algorithm and into sorting algorithms in general, check out Sorting Algorithms in Python .

You can use assignment statements for iterable unpacking in Python. Unpacking an iterable means assigning its values to a series of variables one by one. The iterable must be the right operand in the assignment, while the variables must be the left operand.

Like in parallel assignments, the variables must come as a tuple or list. The number of variables must match the number of values in the iterable. Alternatively, you can use the unpacking operator ( * ) to grab several values in a variable if the number of variables doesn’t match the iterable length.

Here’s the general syntax for iterable unpacking in Python:

Iterable unpacking is a powerful feature that you can use all around your code. It can help you write more readable and concise code. For example, you may find yourself doing something like this:

Whenever you do something like this in your code, go ahead and replace it with a more readable iterable unpacking using a single and elegant assignment, like in the following code snippet:

The numbers list on the right side contains four values. The assignment operator unpacks these values into the four variables on the left side of the statement. The values in numbers get assigned to variables in the same order that they appear in the iterable. The assignment is done by position.

Note: Because Python sets are also iterables, you can use them in an iterable unpacking operation. However, it won’t be clear which value goes to which variable because sets are unordered data structures.

The above example shows the most common form of iterable unpacking in Python. The main condition for the example to work is that the number of variables matches the number of values in the iterable.

What if you don’t know the iterable length upfront? Will the unpacking work? It’ll work if you use the * operator to pack several values into one of your target variables.

For example, say that you want to unpack the first and second values in numbers into two different variables. Additionally, you would like to pack the rest of the values in a single variable conveniently called rest . In this case, you can use the unpacking operator like in the following code:

In this example, first and second hold the first and second values in numbers , respectively. These values are assigned by position. The * operator packs all the remaining values in the input iterable into rest .

The unpacking operator ( * ) can appear at any position in your series of target variables. However, you can only use one instance of the operator:

The iterable unpacking operator works in any position in your list of variables. Note that you can only use one unpacking operator per assignment. Using more than one unpacking operator isn’t allowed and raises a SyntaxError .

Dropping away unwanted values from the iterable is a common use case for the iterable unpacking operator. Consider the following example:

In Python, if you want to signal that a variable won’t be used, then you use an underscore ( _ ) as the variable’s name. In this example, useful holds the only value that you need to use from the input iterable. The _ variable is a placeholder that guarantees that the unpacking works correctly. You won’t use the values that end up in this disposable variable.

Note: In the example above, if your target iterable is a sequence data type, such as a list or tuple, then it’s best to access its last item directly.

To do this, you can use the -1 index:

Using -1 gives you access to the last item of any sequence data type. In contrast, if you’re dealing with iterators , then you won’t be able to use indices. That’s when the *_ syntax comes to your rescue.

The pattern used in the above example comes in handy when you have a function that returns multiple values, and you only need a few of these values in your code. The os.walk() function may provide a good example of this situation.

This function allows you to iterate over the content of a directory recursively. The function returns a generator object that yields three-item tuples. Each tuple contains the following items:

  • The path to the current directory as a string
  • The names of all the immediate subdirectories as a list of strings
  • The names of all the files in the current directory as a list of strings

Now say that you want to iterate over your home directory and list only the files. You can do something like this:

This code will issue a long output depending on the current content of your home directory. Note that you need to provide a string with the path to your user folder for the example to work. The _ placeholder variable will hold the unwanted data.

In contrast, the filenames variable will hold the list of files in the current directory, which is the data that you need. The code will print the list of filenames. Go ahead and give it a try!

The assignment operator also comes in handy when you need to provide default argument values in your functions and methods. Default argument values allow you to define functions that take arguments with sensible defaults. These defaults allow you to call the function with specific values or to simply rely on the defaults.

As an example, consider the following function:

This function takes one argument, called name . This argument has a sensible default value that’ll be used when you call the function without arguments. To provide this sensible default value, you use an assignment.

Note: According to PEP 8 , the style guide for Python code, you shouldn’t use spaces around the assignment operator when providing default argument values in function definitions.

Here’s how the function works:

If you don’t provide a name during the call to greet() , then the function uses the default value provided in the definition. If you provide a name, then the function uses it instead of the default one.

Up to this point, you’ve learned a lot about the Python assignment operator and how to use it for writing different types of assignment statements. In the following sections, you’ll dive into a great feature of assignment statements in Python. You’ll learn about augmented assignments .

Augmented Assignment Operators in Python

Python supports what are known as augmented assignments . An augmented assignment combines the assignment operator with another operator to make the statement more concise. Most Python math and bitwise operators have an augmented assignment variation that looks something like this:

Note that $ isn’t a valid Python operator. In this example, it’s a placeholder for a generic operator. This statement works as follows:

  • Evaluate expression to produce a value.
  • Run the operation defined by the operator that prefixes the = sign, using the previous value of variable and the return value of expression as operands.
  • Assign the resulting value back to variable .

In practice, an augmented assignment like the above is equivalent to the following statement:

As you can conclude, augmented assignments are syntactic sugar . They provide a shorthand notation for a specific and popular kind of assignment.

For example, say that you need to define a counter variable to count some stuff in your code. You can use the += operator to increment counter by 1 using the following code:

In this example, the += operator, known as augmented addition , adds 1 to the previous value in counter each time you run the statement counter += 1 .

It’s important to note that unlike regular assignments, augmented assignments don’t create new variables. They only allow you to update existing variables. If you use an augmented assignment with an undefined variable, then you get a NameError :

Python evaluates the right side of the statement before assigning the resulting value back to the target variable. In this specific example, when Python tries to compute x + 1 , it finds that x isn’t defined.

Great! You now know that an augmented assignment consists of combining the assignment operator with another operator, like a math or bitwise operator. To continue this discussion, you’ll learn which math operators have an augmented variation in Python.

An equation like x = x + b doesn’t make sense in math. But in programming, a statement like x = x + b is perfectly valid and can be extremely useful. It adds b to x and reassigns the result back to x .

As you already learned, Python provides an operator to shorten x = x + b . Yes, the += operator allows you to write x += b instead. Python also offers augmented assignment operators for most math operators. Here’s a summary:

Operator Description Example Equivalent
Adds the right operand to the left operand and stores the result in the left operand
Subtracts the right operand from the left operand and stores the result in the left operand
Multiplies the right operand with the left operand and stores the result in the left operand
Divides the left operand by the right operand and stores the result in the left operand
Performs of the left operand by the right operand and stores the result in the left operand
Finds the remainder of dividing the left operand by the right operand and stores the result in the left operand
Raises the left operand to the power of the right operand and stores the result in the left operand

The Example column provides generic examples of how to use the operators in actual code. Note that x must be previously defined for the operators to work correctly. On the other hand, y can be either a concrete value or an expression that returns a value.

Note: The matrix multiplication operator ( @ ) doesn’t support augmented assignments yet.

Consider the following example of matrix multiplication using NumPy arrays:

Note that the exception traceback indicates that the operation isn’t supported yet.

To illustrate how augmented assignment operators work, say that you need to create a function that takes an iterable of numeric values and returns their sum. You can write this function like in the code below:

In this function, you first initialize total to 0 . In each iteration, the loop adds a new number to total using the augmented addition operator ( += ). When the loop terminates, total holds the sum of all the input numbers. Variables like total are known as accumulators . The += operator is typically used to update accumulators.

Note: Computing the sum of a series of numeric values is a common operation in programming. Python provides the built-in sum() function for this specific computation.

Another interesting example of using an augmented assignment is when you need to implement a countdown while loop to reverse an iterable. In this case, you can use the -= operator:

In this example, custom_reversed() is a generator function because it uses yield . Calling the function creates an iterator that yields items from the input iterable in reverse order. To decrement the control variable, index , you use an augmented subtraction statement that subtracts 1 from the variable in every iteration.

Note: Similar to summing the values in an iterable, reversing an iterable is also a common requirement. Python provides the built-in reversed() function for this specific computation, so you don’t have to implement your own. The above example only intends to show the -= operator in action.

Finally, counters are a special type of accumulators that allow you to count objects. Here’s an example of a letter counter:

To create this counter, you use a Python dictionary. The keys store the letters. The values store the counts. Again, to increment the counter, you use an augmented addition.

Counters are so common in programming that Python provides a tool specially designed to facilitate the task of counting. Check out Python’s Counter: The Pythonic Way to Count Objects for a complete guide on how to use this tool.

The += and *= augmented assignment operators also work with sequences , such as lists, tuples, and strings. The += operator performs augmented concatenations , while the *= operator performs augmented repetition .

These operators behave differently with mutable and immutable data types:

Operator Description Example
Runs an augmented concatenation operation on the target sequence. Mutable sequences are updated in place. If the sequence is immutable, then a new sequence is created and assigned back to the target name.
Adds to itself times. Mutable sequences are updated in place. If the sequence is immutable, then a new sequence is created and assigned back to the target name.

Note that the augmented concatenation operator operates on two sequences, while the augmented repetition operator works on a sequence and an integer number.

Consider the following examples and pay attention to the result of calling the id() function:

Mutable sequences like lists support the += augmented assignment operator through the .__iadd__() method, which performs an in-place addition. This method mutates the underlying list, appending new values to its end.

Note: If the left operand is mutable, then x += y may not be completely equivalent to x = x + y . For example, if you do list_1 = list_1 + list_2 instead of list_1 += list_2 above, then you’ll create a new list instead of mutating the existing one. This may be important if other variables refer to the same list.

Immutable sequences, such as tuples and strings, don’t provide an .__iadd__() method. Therefore, augmented concatenations fall back to the .__add__() method, which doesn’t modify the sequence in place but returns a new sequence.

There’s another difference between mutable and immutable sequences when you use them in an augmented concatenation. Consider the following examples:

With mutable sequences, the data to be concatenated can come as a list, tuple, string, or any other iterable. In contrast, with immutable sequences, the data can only come as objects of the same type. You can concatenate tuples to tuples and strings to strings, for example.

Again, the augmented repetition operator works with a sequence on the left side of the operator and an integer on the right side. This integer value represents the number of repetitions to get in the resulting sequence:

When the *= operator operates on a mutable sequence, it falls back to the .__imul__() method, which performs the operation in place, modifying the underlying sequence. In contrast, if *= operates on an immutable sequence, then .__mul__() is called, returning a new sequence of the same type.

Note: Values of n less than 0 are treated as 0 , which returns an empty sequence of the same data type as the target sequence on the left side of the *= operand.

Note that a_list[0] is a_list[3] returns True . This is because the *= operator doesn’t make a copy of the repeated data. It only reflects the data. This behavior can be a source of issues when you use the operator with mutable values.

For example, say that you want to create a list of lists to represent a matrix, and you need to initialize the list with n empty lists, like in the following code:

In this example, you use the *= operator to populate matrix with three empty lists. Now check out what happens when you try to populate the first sublist in matrix :

The appended values are reflected in the three sublists. This happens because the *= operator doesn’t make copies of the data that you want to repeat. It only reflects the data. Therefore, every sublist in matrix points to the same object and memory address.

If you ever need to initialize a list with a bunch of empty sublists, then use a list comprehension :

This time, when you populate the first sublist of matrix , your changes aren’t propagated to the other sublists. This is because all the sublists are different objects that live in different memory addresses.

Bitwise operators also have their augmented versions. The logic behind them is similar to that of the math operators. The following table summarizes the augmented bitwise operators that Python provides:

Operator Operation Example Equivalent
Augmented bitwise AND ( )
Augmented bitwise OR ( )
Augmented bitwise XOR ( )
Augmented bitwise right shift
Augmented bitwise left shift

The augmented bitwise assignment operators perform the intended operation by taking the current value of the left operand as a starting point for the computation. Consider the following example, which uses the & and &= operators:

Programmers who work with high-level languages like Python rarely use bitwise operations in day-to-day coding. However, these types of operations can be useful in some situations.

For example, say that you’re implementing a Unix-style permission system for your users to access a given resource. In this case, you can use the characters "r" for reading, "w" for writing, and "x" for execution permissions, respectively. However, using bit-based permissions could be more memory efficient:

You can assign permissions to your users with the OR bitwise operator or the augmented OR bitwise operator. Finally, you can use the bitwise AND operator to check if a user has a certain permission, as you did in the final two examples.

You’ve learned a lot about augmented assignment operators and statements in this and the previous sections. These operators apply to math, concatenation, repetition, and bitwise operations. Now you’re ready to look at other assignment variants that you can use in your code or find in other developers’ code.

Other Assignment Variants

So far, you’ve learned that Python’s assignment statements and the assignment operator are present in many different scenarios and use cases. Those use cases include variable creation and initialization, parallel assignments, iterable unpacking, augmented assignments, and more.

In the following sections, you’ll learn about a few variants of assignment statements that can be useful in your future coding. You can also find these assignment variants in other developers’ code. So, you should be aware of them and know how they work in practice.

In short, you’ll learn about:

  • Annotated assignment statements with type hints
  • Assignment expressions with the walrus operator
  • Managed attribute assignments with properties and descriptors
  • Implicit assignments in Python

These topics will take you through several interesting and useful examples that showcase the power of Python’s assignment statements.

PEP 526 introduced a dedicated syntax for variable annotation back in Python 3.6 . The syntax consists of the variable name followed by a colon ( : ) and the variable type:

Even though these statements declare three variables with their corresponding data types, the variables aren’t actually created or initialized. So, for example, you can’t use any of these variables in an augmented assignment statement:

If you try to use one of the previously declared variables in an augmented assignment, then you get a NameError because the annotation syntax doesn’t define the variable. To actually define it, you need to use an assignment.

The good news is that you can use the variable annotation syntax in an assignment statement with the = operator:

The first statement in this example is what you can call an annotated assignment statement in Python. You may ask yourself why you should use type annotations in this type of assignment if everybody can see that counter holds an integer number. You’re right. In this example, the variable type is unambiguous.

However, imagine what would happen if you found a variable initialization like the following:

What would be the data type of each user in users ? If the initialization of users is far away from the definition of the User class, then there’s no quick way to answer this question. To clarify this ambiguity, you can provide the appropriate type hint for users :

Now you’re clearly communicating that users will hold a list of User instances. Using type hints in assignment statements that initialize variables to empty collection data types—such as lists, tuples, or dictionaries—allows you to provide more context about how your code works. This practice will make your code more explicit and less error-prone.

Up to this point, you’ve learned that regular assignment statements with the = operator don’t have a return value. They just create or update variables. Therefore, you can’t use a regular assignment to assign a value to a variable within the context of an expression.

Python 3.8 changed this by introducing a new type of assignment statement through PEP 572 . This new statement is known as an assignment expression or named expression .

Note: Expressions are a special type of statement in Python. Their distinguishing characteristic is that expressions always have a return value, which isn’t the case with all types of statements.

Unlike regular assignments, assignment expressions have a return value, which is why they’re called expressions in the first place. This return value is automatically assigned to a variable. To write an assignment expression, you must use the walrus operator ( := ), which was named for its resemblance to the eyes and tusks of a walrus lying on its side.

The general syntax of an assignment statement is as follows:

This expression looks like a regular assignment. However, instead of using the assignment operator ( = ), it uses the walrus operator ( := ). For the expression to work correctly, the enclosing parentheses are required in most use cases. However, there are certain situations in which these parentheses are superfluous. Either way, they won’t hurt you.

Assignment expressions come in handy when you want to reuse the result of an expression or part of an expression without using a dedicated assignment to grab this value beforehand.

Note: Assignment expressions with the walrus operator have several practical use cases. They also have a few restrictions. For example, they’re illegal in certain contexts, such as lambda functions, parallel assignments, and augmented assignments.

For a deep dive into this special type of assignment, check out The Walrus Operator: Python’s Assignment Expressions .

A particularly handy use case for assignment expressions is when you need to grab the result of an expression used in the context of a conditional statement. For example, say that you need to write a function to compute the mean of a sample of numeric values. Without the walrus operator, you could do something like this:

In this example, the sample size ( n ) is a value that you need to reuse in two different computations. First, you need to check whether the sample has data points or not. Then you need to use the sample size to compute the mean. To be able to reuse n , you wrote a dedicated assignment statement at the beginning of your function to grab the sample size.

You can avoid this extra step by combining it with the first use of the target value, len(sample) , using an assignment expression like the following:

The assignment expression introduced in the conditional computes the sample size and assigns it to n . This way, you guarantee that you have a reference to the sample size to use in further computations.

Because the assignment expression returns the sample size anyway, the conditional can check whether that size equals 0 or not and then take a certain course of action depending on the result of this check. The return statement computes the sample’s mean and sends the result back to the function caller.

Python provides a few tools that allow you to fine-tune the operations behind the assignment of attributes. The attributes that run implicit operations on assignments are commonly referred to as managed attributes .

Properties are the most commonly used tool for providing managed attributes in your classes. However, you can also use descriptors and, in some cases, the .__setitem__() special method.

To understand what fine-tuning the operation behind an assignment means, say that you need a Point class that only allows numeric values for its coordinates, x and y . To write this class, you must set up a validation mechanism to reject non-numeric values. You can use properties to attach the validation functionality on top of x and y .

Here’s how you can write your class:

In Point , you use properties for the .x and .y coordinates. Each property has a getter and a setter method . The getter method returns the attribute at hand. The setter method runs the input validation using a try … except block and the built-in float() function. Then the method assigns the result to the actual attribute.

Here’s how your class works in practice:

When you use a property-based attribute as the left operand in an assignment statement, Python automatically calls the property’s setter method, running any computation from it.

Because both .x and .y are properties, the input validation runs whenever you assign a value to either attribute. In the first example, the input values are valid numbers and the validation passes. In the final example, "one" isn’t a valid numeric value, so the validation fails.

If you look at your Point class, you’ll note that it follows a repetitive pattern, with the getter and setter methods looking quite similar. To avoid this repetition, you can use a descriptor instead of a property.

A descriptor is a class that implements the descriptor protocol , which consists of four special methods :

  • .__get__() runs when you access the attribute represented by the descriptor.
  • .__set__() runs when you use the attribute in an assignment statement.
  • .__delete__() runs when you use the attribute in a del statement.
  • .__set_name__() sets the attribute’s name, creating a name-aware attribute.

Here’s how your code may look if you use a descriptor to represent the coordinates of your Point class:

You’ve removed repetitive code by defining Coordinate as a descriptor that manages the input validation in a single place. Go ahead and run the following code to try out the new implementation of Point :

Great! The class works as expected. Thanks to the Coordinate descriptor, you now have a more concise and non-repetitive version of your original code.

Another way to fine-tune the operations behind an assignment statement is to provide a custom implementation of .__setitem__() in your class. You’ll use this method in classes representing mutable data collections, such as custom list-like or dictionary-like classes.

As an example, say that you need to create a dictionary-like class that stores its keys in lowercase letters:

In this example, you create a dictionary-like class by subclassing UserDict from collections . Your class implements a .__setitem__() method, which takes key and value as arguments. The method uses str.lower() to convert key into lowercase letters before storing it in the underlying dictionary.

Python implicitly calls .__setitem__() every time you use a key as the left operand in an assignment statement. This behavior allows you to tweak how you process the assignment of keys in your custom dictionary.

Implicit Assignments in Python

Python implicitly runs assignments in many different contexts. In most cases, these implicit assignments are part of the language syntax. In other cases, they support specific behaviors.

Whenever you complete an action in the following list, Python runs an implicit assignment for you:

  • Define or call a function
  • Define or instantiate a class
  • Use the current instance , self
  • Import modules and objects
  • Use a decorator
  • Use the control variable in a for loop or a comprehension
  • Use the as qualifier in with statements , imports, and try … except blocks
  • Access the _ special variable in an interactive session

Behind the scenes, Python performs an assignment in every one of the above situations. In the following subsections, you’ll take a tour of all these situations.

When you define a function, the def keyword implicitly assigns a function object to your function’s name. Here’s an example:

From this point on, the name greet refers to a function object that lives at a given memory address in your computer. You can call the function using its name and a pair of parentheses with appropriate arguments. This way, you can reuse greet() wherever you need it.

If you call your greet() function with fellow as an argument, then Python implicitly assigns the input argument value to the name parameter on the function’s definition. The parameter will hold a reference to the input arguments.

When you define a class with the class keyword, you’re assigning a specific name to a class object . You can later use this name to create instances of that class. Consider the following example:

In this example, the name User holds a reference to a class object, which was defined in __main__.User . Like with a function, when you call the class’s constructor with the appropriate arguments to create an instance, Python assigns the arguments to the parameters defined in the class initializer .

Another example of implicit assignments is the current instance of a class, which in Python is called self by convention. This name implicitly gets a reference to the current object whenever you instantiate a class. Thanks to this implicit assignment, you can access .name and .job from within the class without getting a NameError in your code.

Import statements are another variant of implicit assignments in Python. Through an import statement, you assign a name to a module object, class, function, or any other imported object. This name is then created in your current namespace so that you can access it later in your code:

In this example, you import the sys module object from the standard library and assign it to the sys name, which is now available in your namespace, as you can conclude from the second call to the built-in dir() function.

You also run an implicit assignment when you use a decorator in your code. The decorator syntax is just a shortcut for a formal assignment like the following:

Here, you call decorator() with a function object as an argument. This call will typically add functionality on top of the existing function, func() , and return a function object, which is then reassigned to the func name.

The decorator syntax is syntactic sugar for replacing the previous assignment, which you can now write as follows:

Even though this new code looks pretty different from the above assignment, the code implicitly runs the same steps.

Another situation in which Python automatically runs an implicit assignment is when you use a for loop or a comprehension. In both cases, you can have one or more control variables that you then use in the loop or comprehension body:

The memory address of control_variable changes on each iteration of the loop. This is because Python internally reassigns a new value from the loop iterable to the loop control variable on each cycle.

The same behavior appears in comprehensions:

In the end, comprehensions work like for loops but use a more concise syntax. This comprehension creates a new list of strings that mimic the output from the previous example.

The as keyword in with statements, except clauses, and import statements is another example of an implicit assignment in Python. This time, the assignment isn’t completely implicit because the as keyword provides an explicit way to define the target variable.

In a with statement, the target variable that follows the as keyword will hold a reference to the context manager that you’re working with. As an example, say that you have a hello.txt file with the following content:

You want to open this file and print each of its lines on your screen. In this case, you can use the with statement to open the file using the built-in open() function.

In the example below, you accomplish this. You also add some calls to print() that display information about the target variable defined by the as keyword:

This with statement uses the open() function to open hello.txt . The open() function is a context manager that returns a text file object represented by an io.TextIOWrapper instance.

Since you’ve defined a hello target variable with the as keyword, now that variable holds a reference to the file object itself. You confirm this by printing the object and its memory address. Finally, the for loop iterates over the lines and prints this content to the screen.

When it comes to using the as keyword in the context of an except clause, the target variable will contain an exception object if any exception occurs:

In this example, you run a division that raises a ZeroDivisionError . The as keyword assigns the raised exception to error . Note that when you print the exception object, you get only the message because exceptions have a custom .__str__() method that supports this behavior.

There’s a final detail to remember when using the as specifier in a try … except block like the one in the above example. Once you leave the except block, the target variable goes out of scope , and you can’t use it anymore.

Finally, Python’s import statements also support the as keyword. In this context, you can use as to import objects with a different name:

In these examples, you use the as keyword to import the numpy package with the np name and pandas with the name pd . If you call dir() , then you’ll realize that np and pd are now in your namespace. However, the numpy and pandas names are not.

Using the as keyword in your imports comes in handy when you want to use shorter names for your objects or when you need to use different objects that originally had the same name in your code. It’s also useful when you want to make your imported names non-public using a leading underscore, like in import sys as _sys .

The final implicit assignment that you’ll learn about in this tutorial only occurs when you’re using Python in an interactive session. Every time you run a statement that returns a value, the interpreter stores the result in a special variable denoted by a single underscore character ( _ ).

You can access this special variable as you’d access any other variable:

These examples cover several situations in which Python internally uses the _ variable. The first two examples evaluate expressions. Expressions always have a return value, which is automatically assigned to the _ variable every time.

When it comes to function calls, note that if your function returns a fruitful value, then _ will hold it. In contrast, if your function returns None , then the _ variable will remain untouched.

The next example consists of a regular assignment statement. As you already know, regular assignments don’t return any value, so the _ variable isn’t updated after these statements run. Finally, note that accessing a variable in an interactive session returns the value stored in the target variable. This value is then assigned to the _ variable.

Note that since _ is a regular variable, you can use it in other expressions:

In this example, you first create a list of values. Then you call len() to get the number of values in the list. Python automatically stores this value in the _ variable. Finally, you use _ to compute the mean of your list of values.

Now that you’ve learned about some of the implicit assignments that Python runs under the hood, it’s time to dig into a final assignment-related topic. In the following few sections, you’ll learn about some illegal and dangerous assignments that you should be aware of and avoid in your code.

Illegal and Dangerous Assignments in Python

In Python, you’ll find a few situations in which using assignments is either forbidden or dangerous. You must be aware of these special situations and try to avoid them in your code.

In the following sections, you’ll learn when using assignment statements isn’t allowed in Python. You’ll also learn about some situations in which using assignments should be avoided if you want to keep your code consistent and robust.

You can’t use Python keywords as variable names in assignment statements. This kind of assignment is explicitly forbidden. If you try to use a keyword as a variable name in an assignment, then you get a SyntaxError :

Whenever you try to use a keyword as the left operand in an assignment statement, you get a SyntaxError . Keywords are an intrinsic part of the language and can’t be overridden.

If you ever feel the need to name one of your variables using a Python keyword, then you can append an underscore to the name of your variable:

In this example, you’re using the desired name for your variables. Because you added a final underscore to the names, Python doesn’t recognize them as keywords, so it doesn’t raise an error.

Note: Even though adding an underscore at the end of a name is an officially recommended practice , it can be confusing sometimes. Therefore, try to find an alternative name or use a synonym whenever you find yourself using this convention.

For example, you can write something like this:

In this example, using the name booking_class for your variable is way clearer and more descriptive than using class_ .

You’ll also find that you can use only a few keywords as part of the right operand in an assignment statement. Those keywords will generally define simple statements that return a value or object. These include lambda , and , or , not , True , False , None , in , and is . You can also use the for keyword when it’s part of a comprehension and the if keyword when it’s used as part of a ternary operator .

In an assignment, you can never use a compound statement as the right operand. Compound statements are those that require an indented block, such as for and while loops, conditionals, with statements, try … except blocks, and class or function definitions.

Sometimes, you need to name variables, but the desired or ideal name is already taken and used as a built-in name. If this is your case, think harder and find another name. Don’t shadow the built-in.

Shadowing built-in names can cause hard-to-identify problems in your code. A common example of this issue is using list or dict to name user-defined variables. In this case, you override the corresponding built-in names, which won’t work as expected if you use them later in your code.

Consider the following example:

The exception in this example may sound surprising. How come you can’t use list() to build a list from a call to map() that returns a generator of square numbers?

By using the name list to identify your list of numbers, you shadowed the built-in list name. Now that name points to a list object rather than the built-in class. List objects aren’t callable, so your code no longer works.

In Python, you’ll have nothing that warns against using built-in, standard-library, or even relevant third-party names to identify your own variables. Therefore, you should keep an eye out for this practice. It can be a source of hard-to-debug errors.

In programming, a constant refers to a name associated with a value that never changes during a program’s execution. Unlike other programming languages, Python doesn’t have a dedicated syntax for defining constants. This fact implies that Python doesn’t have constants in the strict sense of the word.

Python only has variables. If you need a constant in Python, then you’ll have to define a variable and guarantee that it won’t change during your code’s execution. To do that, you must avoid using that variable as the left operand in an assignment statement.

To tell other Python programmers that a given variable should be treated as a constant, you must write your variable’s name in capital letters with underscores separating the words. This naming convention has been adopted by the Python community and is a recommendation that you’ll find in the Constants section of PEP 8 .

In the following examples, you define some constants in Python:

The problem with these constants is that they’re actually variables. Nothing prevents you from changing their value during your code’s execution. So, at any time, you can do something like the following:

These assignments modify the value of two of your original constants. Python doesn’t complain about these changes, which can cause issues later in your code. As a Python developer, you must guarantee that named constants in your code remain constant.

The only way to do that is never to use named constants in an assignment statement other than the constant definition.

You’ve learned a lot about Python’s assignment operators and how to use them for writing assignment statements . With this type of statement, you can create, initialize, and update variables according to your needs. Now you have the required skills to fully manage the creation and mutation of variables in your Python code.

In this tutorial, you’ve learned how to:

  • Write assignment statements using Python’s assignment operators
  • Work with augmented assignments in Python
  • Explore assignment variants, like assignment expression and managed attributes
  • Identify illegal and dangerous assignments in Python

Learning about the Python assignment operator and how to use it in assignment statements is a fundamental skill in Python. It empowers you to write reliable and effective Python code.

🐍 Python Tricks 💌

Get a short & sweet Python Trick delivered to your inbox every couple of days. No spam ever. Unsubscribe any time. Curated by the Real Python team.

Python Tricks Dictionary Merge

About Leodanis Pozo Ramos

Leodanis Pozo Ramos

Leodanis is an industrial engineer who loves Python and software development. He's a self-taught Python developer with 6+ years of experience. He's an avid technical writer with a growing number of articles published on Real Python and other sites.

Each tutorial at Real Python is created by a team of developers so that it meets our high quality standards. The team members who worked on this tutorial are:

Aldren Santos

Master Real-World Python Skills With Unlimited Access to Real Python

Join us and get access to thousands of tutorials, hands-on video courses, and a community of expert Pythonistas:

Join us and get access to thousands of tutorials, hands-on video courses, and a community of expert Pythonistas:

What Do You Think?

What’s your #1 takeaway or favorite thing you learned? How are you going to put your newfound skills to use? Leave a comment below and let us know.

Commenting Tips: The most useful comments are those written with the goal of learning from or helping out other students. Get tips for asking good questions and get answers to common questions in our support portal . Looking for a real-time conversation? Visit the Real Python Community Chat or join the next “Office Hours” Live Q&A Session . Happy Pythoning!

Keep Learning

Related Topics: intermediate best-practices python

Keep reading Real Python by creating a free account or signing in:

Already have an account? Sign-In

Almost there! Complete this form and click the button below to gain instant access:

Python's Assignment Operator: Write Robust Assignments (Source Code)

🔒 No spam. We take your privacy seriously.

python assignment project

Python Practice for Beginners: 15 Hands-On Problems

Author's photo

  • online practice

Want to put your Python skills to the test? Challenge yourself with these 15 Python practice exercises taken directly from our Python courses!

There’s no denying that solving Python exercises is one of the best ways to practice and improve your Python skills . Hands-on engagement with the language is essential for effective learning. This is exactly what this article will help you with: we've curated a diverse set of Python practice exercises tailored specifically for beginners seeking to test their programming skills.

These Python practice exercises cover a spectrum of fundamental concepts, all of which are covered in our Python Data Structures in Practice and Built-in Algorithms in Python courses. Together, both courses add up to 39 hours of content. They contain over 180 exercises for you to hone your Python skills. In fact, the exercises in this article were taken directly from these courses!

In these Python practice exercises, we will use a variety of data structures, including lists, dictionaries, and sets. We’ll also practice basic programming features like functions, loops, and conditionals. Every exercise is followed by a solution and explanation. The proposed solution is not necessarily the only possible answer, so try to find your own alternative solutions. Let’s get right into it!

Python Practice Problem 1: Average Expenses for Each Semester

John has a list of his monthly expenses from last year:

He wants to know his average expenses for each semester. Using a for loop, calculate John’s average expenses for the first semester (January to June) and the second semester (July to December).

Explanation

We initialize two variables, first_semester_total and second_semester_total , to store the total expenses for each semester. Then, we iterate through the monthly_spending list using enumerate() , which provides both the index and the corresponding value in each iteration. If you have never heard of enumerate() before – or if you are unsure about how for loops in Python work – take a look at our article How to Write a for Loop in Python .

Within the loop, we check if the index is less than 6 (January to June); if so, we add the expense to first_semester_total . If the index is greater than 6, we add the expense to second_semester_total .

After iterating through all the months, we calculate the average expenses for each semester by dividing the total expenses by 6 (the number of months in each semester). Finally, we print out the average expenses for each semester.

Python Practice Problem 2: Who Spent More?

John has a friend, Sam, who also kept a list of his expenses from last year:

They want to find out how many months John spent more money than Sam. Use a for loop to compare their expenses for each month. Keep track of the number of months where John spent more money.

We initialize the variable months_john_spent_more with the value zero. Then we use a for loop with range(len()) to iterate over the indices of the john_monthly_spending list.

Within the loop, we compare John's expenses with Sam's expenses for the corresponding month using the index i . If John's expenses are greater than Sam's for a particular month, we increment the months_john_spent_more variable. Finally, we print out the total number of months where John spent more money than Sam.

Python Practice Problem 3: All of Our Friends

Paul and Tina each have a list of their respective friends:

Combine both lists into a single list that contains all of their friends. Don’t include duplicate entries in the resulting list.

There are a few different ways to solve this problem. One option is to use the + operator to concatenate Paul and Tina's friend lists ( paul_friends and tina_friends ). Afterwards, we convert the combined list to a set using set() , and then convert it back to a list using list() . Since sets cannot have duplicate entries, this process guarantees that the resulting list does not hold any duplicates. Finally, we print the resulting combined list of friends.

If you need a refresher on Python sets, check out our in-depth guide to working with sets in Python or find out the difference between Python sets, lists, and tuples .

Python Practice Problem 4: Find the Common Friends

Now, let’s try a different operation. We will start from the same lists of Paul’s and Tina’s friends:

In this exercise, we’ll use a for loop to get a list of their common friends.

For this problem, we use a for loop to iterate through each friend in Paul's list ( paul_friends ). Inside the loop, we check if the current friend is also present in Tina's list ( tina_friends ). If it is, it is added to the common_friends list. This approach guarantees that we test each one of Paul’s friends against each one of Tina’s friends. Finally, we print the resulting list of friends that are common to both Paul and Tina.

Python Practice Problem 5: Find the Basketball Players

You work at a sports club. The following sets contain the names of players registered to play different sports:

How can you obtain a set that includes the players that are only registered to play basketball (i.e. not registered for football or volleyball)?

This type of scenario is exactly where set operations shine. Don’t worry if you never heard about them: we have an article on Python set operations with examples to help get you up to speed.

First, we use the | (union) operator to combine the sets of football and volleyball players into a single set. In the same line, we use the - (difference) operator to subtract this combined set from the set of basketball players. The result is a set containing only the players registered for basketball and not for football or volleyball.

If you prefer, you can also reach the same answer using set methods instead of the operators:

It’s essentially the same operation, so use whichever you think is more readable.

Python Practice Problem 6: Count the Votes

Let’s try counting the number of occurrences in a list. The list below represent the results of a poll where students were asked for their favorite programming language:

Use a dictionary to tally up the votes in the poll.

In this exercise, we utilize a dictionary ( vote_tally ) to count the occurrences of each programming language in the poll results. We iterate through the poll_results list using a for loop; for each language, we check if it already is in the dictionary. If it is, we increment the count; otherwise, we add the language to the dictionary with a starting count of 1. This approach effectively tallies up the votes for each programming language.

If you want to learn more about other ways to work with dictionaries in Python, check out our article on 13 dictionary examples for beginners .

Python Practice Problem 7: Sum the Scores

Three friends are playing a game, where each player has three rounds to score. At the end, the player whose total score (i.e. the sum of each round) is the highest wins. Consider the scores below (formatted as a list of tuples):

Create a dictionary where each player is represented by the dictionary key and the corresponding total score is the dictionary value.

This solution is similar to the previous one. We use a dictionary ( total_scores ) to store the total scores for each player in the game. We iterate through the list of scores using a for loop, extracting the player's name and score from each tuple. For each player, we check if they already exist as a key in the dictionary. If they do, we add the current score to the existing total; otherwise, we create a new key in the dictionary with the initial score. At the end of the for loop, the total score of each player will be stored in the total_scores dictionary, which we at last print.

Python Practice Problem 8: Calculate the Statistics

Given any list of numbers in Python, such as …

 … write a function that returns a tuple containing the list’s maximum value, sum of values, and mean value.

We create a function called calculate_statistics to calculate the required statistics from a list of numbers. This function utilizes a combination of max() , sum() , and len() to obtain these statistics. The results are then returned as a tuple containing the maximum value, the sum of values, and the mean value.

The function is called with the provided list and the results are printed individually.

Python Practice Problem 9: Longest and Shortest Words

Given the list of words below ..

… find the longest and the shortest word in the list.

To find the longest and shortest word in the list, we initialize the variables longest_word and shortest_word as the first word in the list. Then we use a for loop to iterate through the word list. Within the loop, we compare the length of each word with the length of the current longest and shortest words. If a word is longer than the current longest word, it becomes the new longest word; on the other hand, if it's shorter than the current shortest word, it becomes the new shortest word. After iterating through the entire list, the variables longest_word and shortest_word will hold the corresponding words.

There’s a catch, though: what happens if two or more words are the shortest? In that case, since the logic used is to overwrite the shortest_word only if the current word is shorter – but not of equal length – then shortest_word is set to whichever shortest word appears first. The same logic applies to longest_word , too. If you want to set these variables to the shortest/longest word that appears last in the list, you only need to change the comparisons to <= (less or equal than) and >= (greater or equal than), respectively.

If you want to learn more about Python strings and what you can do with them, be sure to check out this overview on Python string methods .

Python Practice Problem 10: Filter a List by Frequency

Given a list of numbers …

… create a new list containing only the numbers that occur at least three times in the list.

Here, we use a for loop to iterate through the number_list . In the loop, we use the count() method to check if the current number occurs at least three times in the number_list . If the condition is met, the number is appended to the filtered_list .

After the loop, the filtered_list contains only numbers that appear three or more times in the original list.

Python Practice Problem 11: The Second-Best Score

You’re given a list of students’ scores in no particular order:

Find the second-highest score in the list.

This one is a breeze if we know about the sort() method for Python lists – we use it here to sort the list of exam results in ascending order. This way, the highest scores come last. Then we only need to access the second to last element in the list (using the index -2 ) to get the second-highest score.

Python Practice Problem 12: Check If a List Is Symmetrical

Given the lists of numbers below …

… create a function that returns whether a list is symmetrical. In this case, a symmetrical list is a list that remains the same after it is reversed – i.e. it’s the same backwards and forwards.

Reversing a list can be achieved by using the reverse() method. In this solution, this is done inside the is_symmetrical function.

To avoid modifying the original list, a copy is created using the copy() method before using reverse() . The reversed list is then compared with the original list to determine if it’s symmetrical.

The remaining code is responsible for passing each list to the is_symmetrical function and printing out the result.

Python Practice Problem 13: Sort By Number of Vowels

Given this list of strings …

… sort the list by the number of vowels in each word. Words with fewer vowels should come first.

Whenever we need to sort values in a custom order, the easiest approach is to create a helper function. In this approach, we pass the helper function to Python’s sorted() function using the key parameter. The sorting logic is defined in the helper function.

In the solution above, the custom function count_vowels uses a for loop to iterate through each character in the word, checking if it is a vowel in a case-insensitive manner. The loop increments the count variable for each vowel found and then returns it. We then simply pass the list of fruits to sorted() , along with the key=count_vowels argument.

Python Practice Problem 14: Sorting a Mixed List

Imagine you have a list with mixed data types: strings, integers, and floats:

Typically, you wouldn’t be able to sort this list, since Python cannot compare strings to numbers. However, writing a custom sorting function can help you sort this list.

Create a function that sorts the mixed list above using the following logic:

  • If the element is a string, the length of the string is used for sorting.
  • If the element is a number, the number itself is used.

As proposed in the exercise, a custom sorting function named custom_sort is defined to handle the sorting logic. The function checks whether each element is a string or a number using the isinstance() function. If the element is a string, it returns the length of the string for sorting; if it's a number (integer or float), it returns the number itself.

The sorted() function is then used to sort the mixed_list using the logic defined in the custom sorting function.

If you’re having a hard time wrapping your head around custom sort functions, check out this article that details how to write a custom sort function in Python .

Python Practice Problem 15: Filter and Reorder

Given another list of strings, such as the one below ..

.. create a function that does two things: filters out any words with three or fewer characters and sorts the resulting list alphabetically.

Here, we define filter_and_sort , a function that does both proposed tasks.

First, it uses a for loop to filter out words with three or fewer characters, creating a filtered_list . Then, it sorts the filtered list alphabetically using the sorted() function, producing the final sorted_list .

The function returns this sorted list, which we print out.

Want Even More Python Practice Problems?

We hope these exercises have given you a bit of a coding workout. If you’re after more Python practice content, head straight for our courses on Python Data Structures in Practice and Built-in Algorithms in Python , where you can work on exciting practice exercises similar to the ones in this article.

Additionally, you can check out our articles on Python loop practice exercises , Python list exercises , and Python dictionary exercises . Much like this article, they are all targeted towards beginners, so you should feel right at home!

You may also like

python assignment project

How Do You Write a SELECT Statement in SQL?

python assignment project

What Is a Foreign Key in SQL?

python assignment project

Enumerate and Explain All the Basic Elements of an SQL Query

Navigation Menu

Search code, repositories, users, issues, pull requests..., provide feedback.

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly.

To see all available qualifiers, see our documentation .

  • Notifications You must be signed in to change notification settings

This repository is for a 100 day python projects, we'll going to learn together.

seulphoenix/100-day-python-projects

Folders and files.

NameName
2 Commits

Repository files navigation

100-day-python-projects.

  • Python 100.0%

arXiv's Accessibility Forum starts next month!

Help | Advanced Search

Computer Science > Cryptography and Security

Title: an open source python library for anonymizing sensitive data.

Abstract: Open science is a fundamental pillar to promote scientific progress and collaboration, based on the principles of open data, open source and open access. However, the requirements for publishing and sharing open data are in many cases difficult to meet in compliance with strict data protection regulations. Consequently, researchers need to rely on proven methods that allow them to anonymize their data without sharing it with third parties. To this end, this paper presents the implementation of a Python library for the anonymization of sensitive tabular data. This framework provides users with a wide range of anonymization methods that can be applied on the given dataset, including the set of identifiers, quasi-identifiers, generalization hierarchies and allowed level of suppression, along with the sensitive attribute and the level of anonymity required. The library has been implemented following best practices for integration and continuous development, as well as the use of workflows to test code coverage based on unit and functional tests.
Comments: Preprint under review
Subjects: Cryptography and Security (cs.CR); Databases (cs.DB); Software Engineering (cs.SE)
Cite as: [cs.CR]
  (or [cs.CR] for this version)
  Focus to learn more arXiv-issued DOI via DataCite

Submission history

Access paper:.

  • HTML (experimental)
  • Other Formats

license icon

References & Citations

  • Google Scholar
  • Semantic Scholar

BibTeX formatted citation

BibSonomy logo

Bibliographic and Citation Tools

Code, data and media associated with this article, recommenders and search tools.

  • Institution

arXivLabs: experimental projects with community collaborators

arXivLabs is a framework that allows collaborators to develop and share new arXiv features directly on our website.

Both individuals and organizations that work with arXivLabs have embraced and accepted our values of openness, community, excellence, and user data privacy. arXiv is committed to these values and only works with partners that adhere to them.

Have an idea for a project that will add value for arXiv's community? Learn more about arXivLabs .

IMAGES

  1. Practical Python Projects Book

    python assignment project

  2. 5 Python Projects Explained Step-By-Step, Get Started Today

    python assignment project

  3. Step 1. Create and run your first Python project—PyCharm

    python assignment project

  4. Python Assignment Writing

    python assignment project

  5. Python Assignment

    python assignment project

  6. GitHub

    python assignment project

COMMENTS

  1. 25 Python Projects for Beginners

    25 Python Projects for Beginners - Easy Ideas to Get Started Coding Python. Jessica Wilkins. The best way to learn a new programming language is to build projects with it. I have created a list of 25 beginner friendly project tutorials in Python. My advice for tutorials would be to watch the video, build the project, break it apart and ...

  2. 70+ Python Projects for Beginners [Source Code Included]

    Source Code - Mad Libs Generator in Python 2. Python Number Guessing Game. Python Project Idea - This is a fun little project that I like to do in my spare time. It is a number-guessing game written in Python. The basic idea is to have the computer produce a random number between 1 and 100 and then have the user try to guess it.

  3. Python Projects

    Explore project-based Python tutorials and gain practical coding skills. Work on Python projects that help you gain real-world programming experience. These projects include full source code and step-by-step instructions, and will make you more confident in tackling real-world coding challenges.

  4. Python Exercises, Practice, Challenges

    These free exercises are nothing but Python assignments for the practice where you need to solve different programs and challenges. All exercises are tested on Python 3. Each exercise has 10-20 Questions. The solution is provided for every question. These Python programming exercises are suitable for all Python developers.

  5. 100 Python Projects

    Welcome to the "100 Python Projects" repository! Here, we invite you to embark on an incredible journey filled with creativity, problem-solving, and the limitless possibilities of Python programming. Whether you're a beginner or an experienced developer, this repository is designed to provide you with a diverse collection of Python ...

  6. 13 Project Ideas for Intermediate Python Developers

    PySimpleGUI is one of them, and it's pretty user-friendly for an intermediate Python developer. An advanced GUI framework like PyQt5 is quite powerful, but it may have a steep learning curve. The software you create for the Desktop GUI is able to work on any of the Windows, Linux, or Mac operating systems.

  7. 60+ Python Projects for All Levels of Expertise

    Intermediate Python Projects. Going beyond beginner tasks and datasets, this set of Python projects will challenge you by working with non-tabular data sets (e.g., images, audio) and test your machine learning chops on various problems. 1. Classify Song Genres from Audio Data.

  8. 30 Best Python Projects Beginner to Pro With Code [2024]

    5. Dice Roll Generator. As one of the most relatable Python projects for beginners with code, this program simulates rolling one or two dice. It's also a great way to solidify your understanding of user-defined functions, loops, and conditional statements.

  9. 50+ Python Projects with Source Code: Beginner to Advanced

    15. Bitcoin Price Tracker. Stay up-to-date with cryptocurrency trends by creating a Bitcoin Price Tracker in Python. Fetch real-time Bitcoin prices from cryptocurrency APIs and display them in a graphical or text-based interface. This project will introduce you to working with APIs and handling JSON data in Python. 16.

  10. 180 Data Science and Machine Learning Projects with Python

    Data Science Project on-Extracting HOG Features. Data Science Project — Email spam Detection with Machine Learning. Data Science Project — Heart Disease Prediction with Machine. Data Science ...

  11. Best 100+ Python Projects With Source Code

    We are presenting the best python mini projects with source code and links. Here is the list of Simple Python mini projects for beginners: Number Guessing game in Python. Rock Paper Scissors Game. Dice Roller. Simple Calculator GUI. Tic-Tac-Toe. Countdown Timer. QR-code Generator.

  12. Python Projects for Beginner to Advanced

    A good starting project for Python is creating a simple calculator. It helps you practice basic concepts like variables, functions, and conditionals. As you get more comfortable, you can add features like handling more complex calculations or incorporating a graphical user interface using libraries like Tkinter.

  13. 60 Python Projects with Source Code

    Scrape Instagram. Image Filtering. Audio Processing. Analog Clock with Python. Create a Simple Chatbot. Clock APP with Python. 3D Graphs. Calendar GUI. So these were some very useful Python ...

  14. python-assignment · GitHub Topics · GitHub

    To associate your repository with the python-assignment topic, visit your repo's landing page and select "manage topics." GitHub is where people build software. More than 100 million people use GitHub to discover, fork, and contribute to over 420 million projects.

  15. Python Projects, from Beginner to Advanced

    Free Python Projects (Recommended): These free Dataquest guided projects are a great place to start. They provide an embedded code editor directly in your browser, step-by-step instructions to help you complete the project, and community support if you happen to get stuck. Building an Interactive Game — In this guided project, you'll use ...

  16. 290+ Machine Learning Projects with Python

    Data Science Project — Supermarket Sales Analysis. Data Science Project — GDP Analysis. Data Science Project — Predict Customer Churn with Python and Machine Learning. Data Science Project ...

  17. 15 Beginner Python Projects to Practice and Learn

    Easy Python Projects for Beginners in 2024. As building projects and practicing problems is the key to effective learning, we've put together a list of 15 beginner-friendly Python projects and coding questions—all explained with code. These practice problems and projects will start by focusing on fundamentals.

  18. Top 20+ Python Projects With Source Code (2023)

    This Python project uses a Natural Language Processing tool along with a search API to prepare a full-fledged usable Plagiarism checker. What you will need: TensorFlow is an extremely powerful library for building neural networks with a variety of parameters. A neural network consists of an input layer, hidden layers, and an output layer.

  19. Python Online Practice: 93 Unique Coding Exercises

    Practice with Python Projects. One of the most effective ways to practice Python online is with projects. When I was learning Python, it was easy to forget newly acquired skills. When I discovered that I could do projects to practice my newfound knowledge, it helped me remember new syntax. Additionally, I built a great portfolio of work to show ...

  20. Python's Assignment Operator: Write Robust Assignments

    Here, variable represents a generic Python variable, while expression represents any Python object that you can provide as a concrete value—also known as a literal—or an expression that evaluates to a value. To execute an assignment statement like the above, Python runs the following steps: Evaluate the right-hand expression to produce a concrete value or object.

  21. 10 Python Practice Exercises for Beginners with Solutions

    Exercise 1: User Input and Conditional Statements. Write a program that asks the user for a number then prints the following sentence that number of times: 'I am back to check on my skills!'. If the number is greater than 10, print this sentence instead: 'Python conditions and loops are a piece of cake.'.

  22. 2,500+ Python Practice Challenges // Edabit

    Return the Sum of Two Numbers. Create a function that takes two numbers as arguments and returns their sum. Examples addition (3, 2) 5 addition (-3, -6) -9 addition (7, 3) 10 Notes Don't forget to return the result. If you get stuck on a challenge, find help in the Resources tab.

  23. Python Practice for Beginners: 15 Hands-On Problems

    Python Practice Problem 1: Average Expenses for Each Semester. John has a list of his monthly expenses from last year: He wants to know his average expenses for each semester. Using a for loop, calculate John's average expenses for the first semester (January to June) and the second semester (July to December).

  24. seulphoenix/100-day-python-projects

    You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window.

  25. An Open Source Python Library for Anonymizing Sensitive Data

    Open science is a fundamental pillar to promote scientific progress and collaboration, based on the principles of open data, open source and open access. However, the requirements for publishing and sharing open data are in many cases difficult to meet in compliance with strict data protection regulations. Consequently, researchers need to rely on proven methods that allow them to anonymize ...