Real-World Mini Projects

Lesson Overview

Your first practical coding experience! This lesson combines all your Python fundamentals - variables, data types, strings, conditions, loops, and dictionaries - into three realistic Indian scenarios. Each project includes detailed comments showing exactly how the concepts you've mastered work together in real applications.

Lesson Content

Time to Code! Three Practical Python Projects

🌟 Welcome to Your First Real Programming Challenge!

Remember all those concepts you learned? Variables, data types, f-strings, conditions, loops, and dictionaries? Now it's time to see them work together in real Indian scenarios! Each project has detailed comments showing you exactly which concepts are being used and why.

Project 1: Banking Portal for Customer

Scenario: Track your monthly expenses in rupees, categorize spending, and calculate savings for Diwali shopping!

Requirement : You want to build a simple banking system for a customer. After logging in with a username and password, the customer should be able to view their basic account details such as name and current balance. They must also be able to perform core operations like withdrawing money and depositing money into their account. In addition, the system should provide a way to calculate the interest that will be earned on the current balance for the next 12 months

From the requirements, the system can be broken into these clear executable tasks:

  1. Implementation of login : Allow the customer to log in using a name and password.
  2. Display customer details : Once logged in, show the customer’s name and current account balance.
  3. Support money operations : Provide options to deposit money into the account and withdraw money from it with proper checks.
  4. Interest calculation for 12 months : Add a feature to calculate and display the interest on the current balance for each of the next 12 months.

1. Implementation of login

To keep the system closer to a real-world scenario, make a few clear assumptions: use a fixed default password for login, and if the customer enters the wrong password, the system will give them up to five attempts before denying access. Once the customer successfully logs in, automatically initialize their account with a starting balance of 1,00,000 rupees

# Initialize empty dictionary to hold customer data
customer_data = {}            # Will store keys like: name, balance
DEFAULT_PASSWORD = "1234"     # Using a Default Password for every Customer   

print("Welcome to ByLearning Demo Bank")

customer_name = input("Enter your name: ")
customer_name  = customer_name.strip()                            # use Strip method to remove un-wanted space in the given input
customer_name  = customer_name.capitalize()                       # use capitalize method to make the first letter as CAPITAL   
 
# Use a while loop to keep asking for correct password

counter = 1                                                       # Using the couter variable to keep track of no of attempts 
while True:
    entered_password = input("Enter your banking password : ")    # Using input function take the password from user
    entered_password = entered_password.strip()                   # use Strip method to remove un-wanted space in the given input
    print(f'You have entered Passwrod as { entered_password }')   # Using F-String to show the entered password by User
    
    # If - else ladder to check the login conditons

    if entered_password == DEFAULT_PASSWORD:    
        print("Login successful!")
        break                                                     # If Passowrd matches, Login the Customer
    else:
        if counter == 5:
                                                                  # mutli line statement to show the User a detailed message
            print('''
            Incorrect Passowrd was entered 5 times. 
            Your account will be blocked.
            Contact Bank Support Team to un-block your account
            ''')
            break                                                # Go out of loop
        else:
            print("Incorrect password. Please try again ")       # If the retry count is less than 5, show this
           
        
    counter = counter+1                                          # Incremente the Counter
    
# Once user logs in set Name and default balance = 1,00,000 INR
customer_data["name"] = customer_name
customer_data["balance"] = 100000  # 1 Lakh INR

2. Display customer details 

Customer details display is a reusable function because customers need to see their updated name and balance after login, deposits, withdrawals, and interest checks. It ensures consistent professional formatting every time without repeating code


# Example usage after login:
# customer_data = {"name": "Rahul Sharma", "balance": 100000}

def get_customer_info(customer_data) :
    name = customer_data["name"] 
    balance_formatted = customer_data['balance']  
    
    print("="*40)                                            # sting repetitionto make a visual differentiation 
    print("🏦 BYLEARNING DEMO BANK - CUSTOMER PROFILE")
    print("="*40)
    print(f"Customer Name : {name}")
    print(f"Current Balance: ₹{balance_formatted}")
    print("="*40)


# Output:
# ========================================
# BYLEARNING DEMO BANK - CUSTOMER PROFILE
# ========================================
# Customer Name : Rahul Sharma
# Current Balance: ₹100000
# ========================================

3. Support money operations

Withdrawals and deposits are independent, reusable operations that can be implemented as standalone functions. These operations can be performed multiple times (n times) by the customer without needing to recreate the logic each time, making them perfect candidates for functions that can be called repeatedly during a banking session.

#  Function for deposit
def deposit(customer_data, amount):
    # Basic validation
    if amount <= 0:
        print("Deposit amount must be greater than zero.")
        return
    
    # Update balance
    customer_data["balance"] += amount
    print(f"Successfully deposited ₹{amount}.")
    print(f"New balance: ₹{customer_data['balance']}")

#  Function for withdrawal
def withdraw(customer_data, amount):
    if amount <= 0:
        print("Withdrawal amount must be greater than zero.")
        return
    
    if amount > customer_data["balance"]:
        print("Insufficient balance. Transaction cancelled.")
        return
    
    customer_data["balance"] -= amount
    print(f"Successfully withdrew ₹{amount}.")
    print(f"New balance: ₹{customer_data['balance']}")

4. Interest calculation for 12 months

Interest calculation for the next 12 months can be implemented as a reusable function that customers can call anytime to see their projected growth. This function can use a for loop to calculate month-end balances, storing each result in a list to track the progression over the year and display a complete projection table.

# Function to calculate simple interest over next 12 months
def calculate_interest_for_12_months(customer_data,annual_rate_percent):
    """
    Calculates simple interest for each month for the next 12 months
    and prints a month-wise projection.
    
    Formula for simple interest:
    Interest = Principal * Rate * Time
    Here:
    - Principal = current balance
    - Rate = annual_rate_percent / 100
    - Time = months / 12
    """
    
    principal = customer_data["balance"]
    rate = annual_rate_percent / 100                              # convert percentage to float
    
    print("==== INTEREST PROJECTION (NEXT 12 MONTHS) ====")
    print(f"Current Balance : ₹{principal}")
    print(f"Annual Rate     : {annual_rate_percent}%")
    
    # We'll use a list to store month-wise balances
    monthly_balances = []
    
    for month in range(1, 13):                                     # Iterate from 1 to 12
        time_in_years = month / 12                                 # months to years
        interest = principal * rate * time_in_years
        projected_balance = principal + interest
        monthly_balances.append(projected_balance)                 # Adding the month end balance to the list
        
        print(f"Month {month}: Projected balance = ₹{projected_balance}")
    
    print("\nSummary:")
    print(f"Balance after 12 months (simple interest) = ₹{monthly_balances[-1]}")
    print("=============================================")

Implementation: Bringing It All Together with Function Calls

Now that all functions are ready (get_customer_info(), deposit(), withdraw(), calculate_interest_for_12_months()), the main program becomes a simple orchestrator that calls these functions in the right sequence:

Each function handles its own validation, formatting, and logic. The main program just coordinates by calling the right specialist for each task

# Show initial customer data
get_customer_info(customer_data)                     # show the Customer data
deposit(customer_data, 10000)                        # Deposit 10,000
withdraw(customer_data, 60000)                       # Withdraw 60,000
get_customer_info(customer_data)                     # show the Updated Customer data
calculate_interest_for_12_months(customer_data,12)   # show the Intrest table

print("Thank you for using ByLearning Demo Bank!")

Sample Output

Welcome to ByLearning Demo Bank
Enter your name: Hemanth kumar
Enter your banking password : hemanth
You have entered Passwrod as hemanth
Incorrect password. Please try again 
Enter your banking password : 1234
You have entered Passwrod as 1234
Login successful!
========================================
🏦 BYLEARNING DEMO BANK - CUSTOMER PROFILE
========================================
Customer Name : Hemanth kumar
Current Balance: ₹100000
========================================
Successfully deposited ₹10000.
New balance: ₹110000
Successfully withdrew ₹60000.
New balance: ₹50000
========================================
🏦 BYLEARNING DEMO BANK - CUSTOMER PROFILE
========================================
Customer Name : Hemanth kumar
Current Balance: ₹50000
========================================
==== INTEREST PROJECTION (NEXT 12 MONTHS) ====
Current Balance : ₹50000
Annual Rate     : 12%
Month 1: Projected balance = ₹50500.0
Month 2: Projected balance = ₹51000.0
Month 3: Projected balance = ₹51500.0
Month 4: Projected balance = ₹52000.0
Month 5: Projected balance = ₹52500.0
Month 6: Projected balance = ₹53000.0
Month 7: Projected balance = ₹53500.0
Month 8: Projected balance = ₹54000.0
Month 9: Projected balance = ₹54500.0
Month 10: Projected balance = ₹55000.0
Month 11: Projected balance = ₹55500.0
Month 12: Projected balance = ₹56000.0

Summary:
Balance after 12 months (simple interest) = ₹56000.0
=============================================
Thank you for using ByLearning Demo Bank!

Complete Code with Learning Comments:

# Initialize empty dictionary to hold customer data
customer_data = {}            # Will store keys like: name, balance
DEFAULT_PASSWORD = "1234"     # Using a Default Password for every Customer   

print("Welcome to ByLearning Demo Bank")

customer_name = input("Enter your name: ")
customer_name  = customer_name.strip()                            # use Strip method to remove un-wanted space in the given input
customer_name  = customer_name.capitalize()                       # use capitalize method to make the first letter as CAPITAL   
 
# Use a while loop to keep asking for correct password

counter = 1                                                       # Using the couter variable to keep track of no of attempts 
while True:
    entered_password = input("Enter your banking password : ")    # Using input function take the password from user
    entered_password = entered_password.strip()                   # use Strip method to remove un-wanted space in the given input
    print(f'You have entered Passwrod as { entered_password }')   # Using F-String to show the entered password by User
    
    # If - else ladder to check the login conditons

    if entered_password == DEFAULT_PASSWORD:    
        print("Login successful!")
        break                                                     # If Passowrd matches, Login the Customer
    else:
        if counter == 5:
                                                                  # mutli line statement to show the User a detailed message
            print('''
            Incorrect Passowrd was entered 5 times. 
            Your account will be blocked.
            Contact Bank Support Team to un-block your account
            ''')
            break                                                # Go out of loop
        else:
            print("Incorrect password. Please try again ")       # If the retry count is less than 5, show this
           
        
    counter = counter+1                                          # Incremente the Counter
    
# Once user logs in set Name and default balance = 1,00,000 INR
customer_data["name"] = customer_name
customer_data["balance"] = 100000  # 1 Lakh INR



# Example usage after login:
# customer_data = {"name": "Rahul Sharma", "balance": 100000}

def get_customer_info(customer_data) :
    name = customer_data["name"] 
    balance_formatted = customer_data['balance']  
    
    print("="*40)                                            # sting repetitionto make a visual differentiation 
    print("🏦 BYLEARNING DEMO BANK - CUSTOMER PROFILE")
    print("="*40)
    print(f"Customer Name : {name}")
    print(f"Current Balance: ₹{balance_formatted}")
    print("="*40)

# 4. Function for deposit
def deposit(customer_data, amount):
    # Basic validation
    if amount <= 0:
        print("Deposit amount must be greater than zero.")
        return
    
    # Update balance
    customer_data["balance"] += amount
    print(f"Successfully deposited ₹{amount}.")
    print(f"New balance: ₹{customer_data['balance']}")

# 4. Function for withdrawal
def withdraw(customer_data, amount):
    if amount <= 0:
        print("Withdrawal amount must be greater than zero.")
        return
    
    if amount > customer_data["balance"]:
        print("Insufficient balance. Transaction cancelled.")
        return
    
    customer_data["balance"] -= amount
    print(f"Successfully withdrew ₹{amount}.")
    print(f"New balance: ₹{customer_data['balance']}")
    
# Function to calculate simple interest over next 12 months
def calculate_interest_for_12_months(customer_data,annual_rate_percent):
    """
    Calculates simple interest for each month for the next 12 months
    and prints a month-wise projection.
    
    Formula for simple interest:
    Interest = Principal * Rate * Time
    Here:
    - Principal = current balance
    - Rate = annual_rate_percent / 100
    - Time = months / 12
    """
    
    principal = customer_data["balance"]
    rate = annual_rate_percent / 100                              # convert percentage to float
    
    print("==== INTEREST PROJECTION (NEXT 12 MONTHS) ====")
    print(f"Current Balance : ₹{principal}")
    print(f"Annual Rate     : {annual_rate_percent}%")
    
    # We'll use a list to store month-wise balances
    monthly_balances = []
    
    for month in range(1, 13):                                     # Iterate from 1 to 12
        time_in_years = month / 12                                 # months to years
        interest = principal * rate * time_in_years
        projected_balance = principal + interest
        monthly_balances.append(projected_balance)                 # Adding the month end balance to the list
        
        print(f"Month {month}: Projected balance = ₹{projected_balance}")
    
    print("\nSummary:")
    print(f"Balance after 12 months (simple interest) = ₹{monthly_balances[-1]}")
    print("=============================================")


#Implementation
# Show initial customer data
get_customer_info(customer_data)                     # show the Customer data
deposit(customer_data, 10000)                        # Deposit 10,000
withdraw(customer_data, 60000)                       # Withdraw 60,000
get_customer_info(customer_data)                     # show the Updated Customer data
calculate_interest_for_12_months(customer_data,12)   # show the Intrest table

print("Thank you for using ByLearning Demo Bank!")

🎓 What You've Just Accomplished!

Look at these three complete, functional programs you now understand! Each one uses every single concept you've learned:

✅ Concepts Successfully Applied:

  • Variables & Data Types: Integers, floats, strings storing real data
  • Dictionaries: Organizing complex data with meaningful keys
  • F-strings: Creating dynamic, formatted output messages
  • Conditions: Making intelligent decisions in your programs
  • Loops: Processing multiple items efficiently
  • String Methods: Cleaning and formatting user input
  • Type Conversion: Converting user input safely

🚀 Your Challenge:

Run these programs, experiment with them, and try to modify them! Add new features, change the context, or combine concepts from different projects. You're now officially a Python programmer!