23, IInd Floor, D-Block Ranjit Avenue, Amritsar, 143001
info@webcooks.in
+91 91151 44444 | +91 82838 09241

7 Python Projects Beginner Can Learn and Code

Explore 7 beginner-friendly Python projects that will help you practice coding and master essential programming concepts. From building a simple calculator to creating a Tic-Tac-Toe game, these projects offer hands-on experience in Python development for new programmers.

Hi learners! Lets ‘s begin with learning Python. Learning Python is a wonderful adventure as it is easy and holds the most fascinating area of application. Whereas, mere learning will not help a person to be a good programmer. Your real growth comes from practicing and working on hands-on projects.
the old one.
No need to start with big python projects. You can even  start with small, achievable tasks, to apply your knowledge, gain confidence, and improve problem-solving abilities.

Whether you’re learning Python for academic purposes, work, or personal development, these examples will help you take your first steps into the world of coding.

Why Choose These Python Projects?

1. Practical Application:

These provide hands-on experience to practice Python programming concepts

2. Reinforce Concepts:

Each project is focused on key concepts, including loops, conditionals, functions, and file handling.

3. Easy to Expand:

These projects can be enhanced with additional features, offering opportunities for further learning.

4. Real-Life Relevance:

The projects simulate real-world scenarios, making them both engaging and useful.

Have a look on 7 Python Projects that you can start with

We will explore 7 beginner-friendly Python projects that you can build step by step. These projects are actually entertaining besides being fun exercises to grasp vital programming ideas.

1. Simple Calculator Using Python

A basic calculator is an ideal starting project. All the beginners can start building a simple calculator, which introduces all the basic principles such as functions, taking input from the user, and making use of conditional statements in Python.

Project Overview:

This project lets you create a simple calculator that can handle basic math operations like addition, subtraction, multiplication, and division.

Users input two numbers and choose the operation they wish to perform.

What You’ll Learn: 

Functions: Learn to organize code into reusable functions.
Conditional Statements: Understand how to use if-else to make decisions.
User Input: Practice collecting input using the `input()` function.

Why This Project? 

This project covers the basics of Python programming and gives you a practical tool that is simple yet expandable.

SAMPLE CODE:

				
					def calculator():
    print("Welcome to the Python Calculator!")
    print("Choose an operation:")
    print("1. Addition")
    print("2. Subtraction")
    print("3. Multiplication")
    print("4. Division")
    print("5. Exit")

    while True:
        try:
            choice = int(input("\nEnter your choice (1-5): "))

            if choice == 5:
                print("Thank you for using the calculator. Goodbye!")
                break
            
            if choice not in range(1, 6):
                print("Invalid choice. Please try again.")
                continue

            num1 = float(input("Enter the first number: "))
            num2 = float(input("Enter the second number: "))

            if choice == 1:
                print(f"The result is: {num1 + num2}")
            elif choice == 2:
                print(f"The result is: {num1 - num2}")
            elif choice == 3:
                print(f"The result is: {num1 * num2}")
            elif choice == 4:
                if num2 == 0:
                    print("Error: Division by zero is not allowed.")
                else:
                    print(f"The result is: {num1 / num2}")

        except ValueError:
            print("Invalid input. Please enter a number.")

# Call the calculator function to run
calculator()

				
			

2. Tic-Tac-Toe

Tic-Tac-Toe, one of the games mostly played by two players, is not only fun to play but also very interesting to code as well.

Project Overview:

Players take turns marking spots on a 3×3 grid. The game is ended when a player gets three marks in a row or fills the grid.

What You’ll Learn:

Using Lists: Represent the board of the game in the form of a 2D list.
Loops: Use loops to take turns and update the board.
Game Logic: Implement logic to check for wins or a draw.

Why This Project?

It is an excellent introduction to working with lists, loops, and decision-making while teaching you how to think through game logic.

SAMPLE CODE:

				
					# Function to initialize the game board
def initialize_board():
    return [[" " for _ in range(3)] for _ in range(3)]  # 3x3 grid with empty spaces

# Function to print the game board
def print_board(board):
    for row in board:
        print(" | ".join(row))
        print("-" * 9)

# Function to check if a player has won
def check_winner(board, player):
    # Check rows, columns, and diagonals for a win
    for row in board:
        if all(spot == player for spot in row):
            return True

    for col in range(3):
        if all(board[row][col] == player for row in range(3)):
            return True

    if all(board[i][i] == player for i in range(3)) or all(board[i][2 - i] == player for i in range(3)):
        return True

    return False

# Function to check if the board is full (draw)
def is_draw(board):
    return all(board[row][col] != " " for row in range(3) for col in range(3))

# Function to play the game
def play_tic_tac_toe():
    print("Welcome to Tic-Tac-Toe!")
    print("Player 1 is 'X' and Player 2 is 'O'.")
    board = initialize_board()  # Initialize the game board
    current_player = 'X'       # Player 'X' starts the game

    while True:
        print("\nCurrent Board:")
        print_board(board)

        # Ask the current player for their move
        try:
            move = input(f"Player {current_player}, enter your move as row,col (e.g., 1,2): ")
            row, col = map(int, move.split(","))
            row -= 1  # Adjust for 0-based indexing
            col -= 1

            if row < 0 or row >= 3 or col < 0 or col >= 3 or board[row][col] != " ":
                print("Invalid move. Please try again.")
                continue

            # Place the player's mark on the board
            board[row][col] = current_player

            # Check for a winner
            if check_winner(board, current_player):
                print("\nFinal Board:")
                print_board(board)
                print(f"Congratulations! Player {current_player} wins!")
                break

            # Check for a draw
            if is_draw(board):
                print("\nFinal Board:")
                print_board(board)
                print("It's a draw!")
                break

            # Switch players
            current_player = 'O' if current_player == 'X' else 'X'

        except ValueError:
            print("Invalid input. Please enter row and column as numbers separated by a comma.")

# Start the game
play_tic_tac_toe()

				
			

3. Hostel Management System

This project demonstrates how Python can be used to automate tasks such as managing data for a hostel. It includes from Python basics to advance concepts

Project Overview:

The system allows users to manage room assignments, guest details, and fees. It also supports updating and retrieving data.

What You’ll Learn:

Dictionaries: Organize data efficiently.
File Handling: Store and retrieve data from files.
Interactive Menus: Create a menu-based interface for user interaction.

Why This Project?

It introduces real-world applications of Python while building skills in data management.

SAMPLE CODE:

				
					import json

# File to store hostel data
DATA_FILE = "hostel_data.json"

# Function to load data from the file
def load_data():
    try:
        with open(DATA_FILE, "r") as file:
            return json.load(file)
    except FileNotFoundError:
        return {}

# Function to save data to the file
def save_data(data):
    with open(DATA_FILE, "w") as file:
        json.dump(data, file, indent=4)

# Function to add a new guest
def add_guest(hostel_data):
    room_number = input("Enter room number: ")
    if room_number in hostel_data:
        print("Room is already occupied.")
        return
    name = input("Enter guest name: ")
    age = input("Enter guest age: ")
    fees_paid = input("Has the guest paid the fees? (yes/no): ").lower() == "yes"
    hostel_data[room_number] = {
        "name": name,
        "age": age,
        "fees_paid": fees_paid
    }
    print(f"Guest {name} added to room {room_number}.")

# Function to view guest details
def view_guest(hostel_data):
    room_number = input("Enter room number: ")
    if room_number in hostel_data:
        guest = hostel_data[room_number]
        print(f"Room {room_number}:")
        print(f" Name: {guest['name']}")
        print(f" Age: {guest['age']}")
        print(f" Fees Paid: {'Yes' if guest['fees_paid'] else 'No'}")
    else:
        print("Room not found or empty.")

# Function to update guest details
def update_guest(hostel_data):
    room_number = input("Enter room number: ")
    if room_number not in hostel_data:
        print("Room not found.")
        return
    guest = hostel_data[room_number]
    print("Current Details:")
    print(f" Name: {guest['name']}")
    print(f" Age: {guest['age']}")
    print(f" Fees Paid: {'Yes' if guest['fees_paid'] else 'No'}")
    
    guest['name'] = input("Enter new name (leave blank to keep current): ") or guest['name']
    guest['age'] = input("Enter new age (leave blank to keep current): ") or guest['age']
    fees_paid_input = input("Has the guest paid the fees? (yes/no/blank to keep current): ").lower()
    
    if fees_paid_input:
        guest['fees_paid'] = fees_paid_input == "yes"
    
    print("Guest details updated.")

# Function to remove a guest
def remove_guest(hostel_data):
    room_number = input("Enter room number: ")
    if room_number in hostel_data:
        del hostel_data[room_number]
        print(f"Guest in room {room_number} removed.")
    else:
        print("Room not found.")

# Function to pay fees for a guest
def pay_fees(hostel_data):
    room_number = input("Enter room number: ")
    if room_number in hostel_data:
        guest = hostel_data[room_number]
        if guest['fees_paid']:
            print(f"Fees for guest {guest['name']} in room {room_number} are already paid.")
        else:
            guest['fees_paid'] = True
            print(f"Fees for guest {guest['name']} in room {room_number} have been paid.")
    else:
        print("Room not found.")

# Main menu
def main():
    print("Welcome to the Hostel Management System!")
    hostel_data = load_data()
    while True:
        print("\nMenu:")
        print("1. Add Guest")
        print("2. View Guest Details")
        print("3. Update Guest Details")
        print("4. Remove Guest")
        print("5. Pay Fees")
        print("6. Exit")
        
        choice = input("Enter your choice: ")
        
        if choice == "1":
            add_guest(hostel_data)
        elif choice == "2":
            view_guest(hostel_data)
        elif choice == "3":
            update_guest(hostel_data)
        elif choice == "4":
            remove_guest(hostel_data)
        elif choice == "5":
            pay_fees(hostel_data)
        elif choice == "6":
            save_data(hostel_data)
            print("Data saved. Exiting system. Goodbye!")
            break
        else:
            print("Invalid choice. Please try again.")

# Run the program
main()

				
			

4. Library Management System

This project focuses on managing books by allowing users to borrow, return, and check availability.

What You’ll Learn:

File Handling: Save and retrieve book data.
Error Handling: Manage exceptions to ensure smooth program operation.
CRUD Operations: Implement the functionalities for Create, Read, Update and Delete.

SAMPLE CODE:

				
					import os

class LibraryManagementSystem:
    def __init__(self, filename="books.txt"):
        self.filename = filename
        if not os.path.exists(self.filename):
            with open(self.filename, 'w') as file:
                pass  # Create the file if it doesn't exist

    def display_books(self):
        """Display all available books."""
        try:
            with open(self.filename, 'r') as file:
                books = file.readlines()
                if not books:
                    print("No books available.")
                else:
                    print("Available Books:")
                    for book in books:
                        print(book.strip())
        except Exception as e:
            print(f"Error reading file: {e}")

    def add_book(self, book_name):
        """Add a new book."""
        if not book_name.strip():
            print("Error: Book name cannot be empty.")
            return
        try:
            with open(self.filename, 'a') as file:
                file.write(book_name + '\n')
            print(f"Book '{book_name}' added successfully.")
        except Exception as e:
            print(f"Error adding book: {e}")

    def borrow_book(self, book_name):
        """Allow users to borrow a book."""
        try:
            with open(self.filename, 'r') as file:
                books = file.readlines()

            book_found = False
            with open(self.filename, 'w') as file:
                for book in books:
                    if book.strip() != book_name:
                        file.write(book)
                    else:
                        book_found = True

            if book_found:
                print(f"You have borrowed '{book_name}' successfully.")
            else:
                print(f"Sorry, '{book_name}' is not available.")
        except Exception as e:
            print(f"Error borrowing book: {e}")

    def return_book(self, book_name):
        """Allow users to return a borrowed book."""
        self.add_book(book_name)  # Return by adding the book back
        print(f"Thank you for returning '{book_name}'.")

    def update_book(self, old_name, new_name):
        """Update the name of a book."""
        if not new_name.strip():
            print("Error: New book name cannot be empty.")
            return
        try:
            with open(self.filename, 'r') as file:
                books = file.readlines()

            book_found = False
            with open(self.filename, 'w') as file:
                for book in books:
                    if book.strip() == old_name:
                        file.write(new_name + '\n')
                        book_found = True
                    else:
                        file.write(book)

            if book_found:
                print(f"Book '{old_name}' updated to '{new_name}'.")
            else:
                print(f"Book '{old_name}' not found.")
        except Exception as e:
            print(f"Error updating book: {e}")

    def delete_book(self, book_name):
        """Delete a book from the library."""
        try:
            with open(self.filename, 'r') as file:
                books = file.readlines()

            book_found = False
            with open(self.filename, 'w') as file:
                for book in books:
                    if book.strip() != book_name:
                        file.write(book)
                    else:
                        book_found = True

            if book_found:
                print(f"Book '{book_name}' deleted successfully.")
            else:
                print(f"Book '{book_name}' not found.")
        except Exception as e:
            print(f"Error deleting book: {e}")


# Example Usage
library = LibraryManagementSystem()

# Add books
library.add_book("The Great Gatsby")
library.add_book("1984")
library.add_book("To Kill a Mockingbird")

# Display all books
library.display_books()

# Borrow a book
library.borrow_book("1984")

# Return a book
library.return_book("1984")

# Update a book's name
library.update_book("The Great Gatsby", "The Great Gatsby - New Edition")

# Delete a book
library.delete_book("To Kill a Mockingbird")

# Display all books after changes
library.display_books()

				
			

 
5. ATM Simulation

Simulate an ATM system to explore interactive Python programming for beginners.

Project Overview: This program provides balance inquiry, deposit, and withdrawal options.

What You’ll Learn:

Dictionaries: Store account-related data.
Input Validation: Ensure users provide correct input.
Menu-Based Programming: Guide users through a series of choices.

SAMPLE CODE:

				
					class ATMSimulation:
    def __init__(self):
        # Dictionary to store account details {account_number: {"pin": ..., "balance": ...}}
        self.accounts = {}

    def create_account(self, account_number, pin, initial_balance=0):
        """Create a new account."""
        if account_number in self.accounts:
            print("Account already exists.")
        else:
            self.accounts[account_number] = {"pin": pin, "balance": initial_balance}
            print(f"Account {account_number} created successfully with balance {initial_balance}.")

    def validate_account(self, account_number, pin):
        """Validate account number and PIN."""
        if account_number in self.accounts and self.accounts[account_number]["pin"] == pin:
            return True
        return False

    def balance_inquiry(self, account_number):
        """Check account balance."""
        print(f"Current balance: {self.accounts[account_number]['balance']}")

    def deposit(self, account_number, amount):
        """Deposit money into the account."""
        if amount > 0:
            self.accounts[account_number]["balance"] += amount
            print(f"Deposited {amount}. New balance: {self.accounts[account_number]['balance']}")
        else:
            print("Invalid deposit amount. Please enter a positive value.")

    def withdraw(self, account_number, amount):
        """Withdraw money from the account."""
        if 0 < amount <= self.accounts[account_number]["balance"]:
            self.accounts[account_number]["balance"] -= amount
            print(f"Withdrawn {amount}. Remaining balance: {self.accounts[account_number]['balance']}")
        elif amount > self.accounts[account_number]["balance"]:
            print("Insufficient balance.")
        else:
            print("Invalid withdrawal amount. Please enter a positive value.")

    def main_menu(self):
        """Display the main menu."""
        while True:
            print("\n--- ATM Simulation ---")
            print("1. Create Account")
            print("2. Login to Account")
            print("3. Exit")
            choice = input("Enter your choice: ")
            if choice == "1":
                self.create_account_menu()
            elif choice == "2":
                self.account_menu()
            elif choice == "3":
                print("Thank you for using the ATM. Goodbye!")
                break
            else:
                print("Invalid choice. Please try again.")

    def create_account_menu(self):
        """Menu for creating a new account."""
        account_number = input("Enter a new account number: ")
        pin = input("Set a 4-digit PIN: ")
        while len(pin) != 4 or not pin.isdigit():
            print("PIN must be a 4-digit number. Please try again.")
            pin = input("Set a 4-digit PIN: ")

        initial_balance = input("Enter an initial deposit amount (or leave empty for 0): ")
        initial_balance = float(initial_balance) if initial_balance.strip() else 0
        self.create_account(account_number, pin, initial_balance)

    def account_menu(self):
        """Menu for logged-in account operations."""
        account_number = input("Enter your account number: ")
        pin = input("Enter your PIN: ")
        if self.validate_account(account_number, pin):
            print("Login successful!")
            while True:
                print("\n--- Account Menu ---")
                print("1. Balance Inquiry")
                print("2. Deposit")
                print("3. Withdraw")
                print("4. Logout")
                choice = input("Enter your choice: ")
                if choice == "1":
                    self.balance_inquiry(account_number)
                elif choice == "2":
                    try:
                        amount = float(input("Enter amount to deposit: "))
                        self.deposit(account_number, amount)
                    except ValueError:
                        print("Invalid amount. Please enter a numeric value.")
                elif choice == "3":
                    try:
                        amount = float(input("Enter amount to withdraw: "))
                        self.withdraw(account_number, amount)
                    except ValueError:
                        print("Invalid amount. Please enter a numeric value.")
                elif choice == "4":
                    print("Logged out successfully.")
                    break
                else:
                    print("Invalid choice. Please try again.")
        else:
            print("Invalid account number or PIN.")


# Run the ATM Simulation
atm = ATMSimulation()
atm.main_menu()

				
			

6. Guess the Number Game

A fun, interactive project where users attempt to guess a random number created by the program.

What You’ll Learn:

Random Numbers: Use Python’s `random` module.
Loops: Repeatedly prompt the user for input.
Conditionals: Provide hints to help the user guess correctly.

SAMPLE CODE:

				
					import random

def guess_the_number():
    print("Welcome to the Guess the Number Game!")
    print("I have chosen a number between 1 and 100. Can you guess what it is?")
    
    # Generate a random number between 1 and 100
    secret_number = random.randint(1, 100)
    attempts = 0  # Track the number of attempts
    
    while True:
        try:
            # Prompt the user to guess the number
            guess = int(input("Enter your guess: "))
            attempts += 1
            
            # Provide feedback based on the guess
            if guess < secret_number:
                print("Too low! Try again.")
            elif guess > secret_number:
                print("Too high! Try again.")
            else:
                print(f"Congratulations! You guessed it in {attempts} attempts.")
                break  # Exit the loop if the guess is correct
        except ValueError:
            # Handle invalid input
            print("Invalid input. Please enter a valid number.")

# Start the game
guess_the_number()

				
			

7. To-Do List Application

Design a single task management application to help users organize their day.

Project Overview: Users can add, view, and remove tasks, with data stored for future use.

What You’ll Learn:

Lists: Manage tasks efficiently.
Persistent Storage: Use file handling to save tasks.

SAMPLE CODE:

				
					import os

class ToDoList:
    def __init__(self, filename="tasks.txt"):
        self.filename = filename
        self.tasks = []
        self.load_tasks()

    def load_tasks(self):
        """Load tasks from the file."""
        if os.path.exists(self.filename):
            with open(self.filename, 'r') as file:
                self.tasks = [task.strip() for task in file.readlines()]
        else:
            self.tasks = []

    def save_tasks(self):
        """Save tasks to the file."""
        with open(self.filename, 'w') as file:
            for task in self.tasks:
                file.write(task + '\n')

    def view_tasks(self):
        """View all tasks."""
        if self.tasks:
            print("\n--- Your To-Do List ---")
            for idx, task in enumerate(self.tasks, start=1):
                print(f"{idx}. {task}")
        else:
            print("\nYour to-do list is empty!")

    def add_task(self, task):
        """Add a new task."""
        self.tasks.append(task)
        self.save_tasks()
        print(f"Task '{task}' added successfully!")

    def remove_task(self, task_number):
        """Remove a task by its number."""
        if 1 <= task_number <= len(self.tasks):
            removed_task = self.tasks.pop(task_number - 1)
            self.save_tasks()
            print(f"Task '{removed_task}' removed successfully!")
        else:
            print("Invalid task number. Please try again.")

    def main_menu(self):
        """Display the main menu."""
        while True:
            print("\n--- To-Do List Application ---")
            print("1. View Tasks")
            print("2. Add Task")
            print("3. Remove Task")
            print("4. Exit")
            choice = input("Enter your choice: ")

            if choice == "1":
                self.view_tasks()
            elif choice == "2":
                task = input("Enter the task: ")
                self.add_task(task)
            elif choice == "3":
                self.view_tasks()
                try:
                    task_number = int(input("Enter the task number to remove: "))
                    self.remove_task(task_number)
                except ValueError:
                    print("Invalid input. Please enter a number.")
            elif choice == "4":
                print("Thank you for using the To-Do List Application. Goodbye!")
                break
            else:
                print("Invalid choice. Please try again.")

# Run the To-Do List Application
todo_app = ToDoList()
todo_app.main_menu()

				
			

Tips for Beginner Python Programmers

  • Break the problem into smaller, manageable tasks before starting. Plan your code structure and logic step by step to simplify the development process.
  • Write pseudocode to outline your solution.
  • Test each part of your project to identify and fix bugs early.
  • Utilize Python’s documentation and online forums for additional support.

Conclusion

These seven projects are perfect for beginners to practice coding and create a strong foundation of knowledge of Python. They allow you to apply theoretical knowledge, improve problem-solving skills, and gain hands-on experience with essential concepts like functions, loops, and file handling. Use these exercises to master the skills and confidence for going ahead with more complex programming tasks. Once you complete them, try adding new features or modifying the projects to suit your interests—this will challenge you further and help you refine your skills. Happy coding!

7 Python Projects Beginner Can Learn and Code

Explore 7 beginner-friendly Python projects that will help you practice coding and master essential programming concepts. From building a simple calculator to creating a Tic-Tac-Toe game, these projects offer hands-on experience in Python development for new programmers.

Scroll to Top