This page contains the NCERT Computer Science class 12 chapter 13 Project Based Learning. You can find the solutions for the chapter 13 of NCERT class 12 Computer Science Exercise. So is the case if you are looking for NCERT class 12 Computer Science related topic Project Based Learning questions and answers for the Exercise
Projects
Project 1
Project Title 1: Automation of Order Processing in a Restaurant.
Description:
A new restaurant “Stay Healthy” is coming up in your locality. The owner/management of the restaurant wants to use a computer to generate bills and maintain other records of the restaurant. Your team is asked to develop an application software to automate the order placing and associated processes.
Specifications:
Make a group of students to undertake a project on automating the order processing of the restaurant “Stay Healthy”. The owner of the restaurant wants the following specific functionalities to be made available in the developed application:
•
There should be two types of Login options — one for the manager of the joint and other for the customer.
•
Kiosk(s) running the software for customers will be placed at reception for placing the order. On the opening screen, menu for placing orders will be displayed.
•
To place orders, customers will enter Item Code(s) and quantity desired.
•
After placing an order, a soft copy of the bill will be displayed on the kiosk, having an Order Number.
•
Every bill will have a unique identification (such as combination of date and order number of the day) and should be saved in the data file/database.
•
Order Number starts from 1 every day.
•
For Manager login—provision for entry/change of Menu, deletion of Order (on demand) and generation of following report is desired.
✔ A Report giving Summary of the Sales made on a Day. Program should accept the date for which the Summary is required.
•
Add at least one more relevant report of your choice to the program.
Answer 1
Python Solution
Files used:
menu.txt, bills.txt, last_order.txt (all are plain text)import os
from datetime import datetime
# ----------------------------
# File names (plain text files)
# ----------------------------
MENU_FILE = "menu.txt"
BILLS_FILE = "bills.txt"
LAST_ORDER_FILE = "last_order.txt"
# ----------------------------
# Utility functions (simple)
# ----------------------------
def ensure_menu_file():
# If menu file does not exist, create a small default menu
if not os.path.exists(MENU_FILE):
f = open(MENU_FILE, "w")
f.write("I101|Salad|120\n")
f.write("I102|Soup|90\n")
f.write("I103|Sandwich|150\n")
f.write("I104|Juice|80\n")
f.close()
def load_menu():
# Returns menu as dictionary: code -> (name, price)
ensure_menu_file()
menu = {}
f = open(MENU_FILE, "r")
for line in f:
line = line.strip()
if line != "":
parts = line.split("|")
code = parts[0]
name = parts[1]
price = float(parts[2])
menu[code] = (name, price)
f.close()
return menu
def save_menu(menu):
# Saves full menu back to file
f = open(MENU_FILE, "w")
for code in menu:
name = menu[code][0]
price = menu[code][1]
f.write(code + "|" + name + "|" + str(price) + "\n")
f.close()
def display_menu(menu):
print("\n--- MENU ---")
print("Code Name Price")
for code in menu:
name = menu[code][0]
price = menu[code][1]
print(code + " " + name.ljust(10) + " " + str(price))
print("------------\n")
def get_today_date_str():
# Date string used in unique bill id
return datetime.now().strftime("%Y-%m-%d")
def get_next_order_number():
# Order number starts from 1 every day
today = get_today_date_str()
last_date = ""
last_no = 0
if os.path.exists(LAST_ORDER_FILE):
f = open(LAST_ORDER_FILE, "r")
data = f.read().strip()
f.close()
if data != "":
parts = data.split("|")
last_date = parts[0]
last_no = int(parts[1])
if last_date != today:
order_no = 1
else:
order_no = last_no + 1
# Save today's last order number
f = open(LAST_ORDER_FILE, "w")
f.write(today + "|" + str(order_no))
f.close()
return order_no
def append_bill_line(bill_id, date_str, order_no, items_text, total):
# Bills file line format:
# bill_id|date|order_no|items|total
f = open(BILLS_FILE, "a")
f.write(bill_id + "|" + date_str + "|" + str(order_no) + "|" + items_text + "|" + str(total) + "\n")
f.close()
def read_all_bills():
bills = []
if not os.path.exists(BILLS_FILE):
return bills
f = open(BILLS_FILE, "r")
for line in f:
line = line.strip()
if line != "":
bills.append(line)
f.close()
return bills
def write_all_bills(lines):
f = open(BILLS_FILE, "w")
for line in lines:
f.write(line + "\n")
f.close()
# ----------------------------
# Customer section
# ----------------------------
def customer_place_order():
menu = load_menu()
display_menu(menu)
cart = {} # code -> qty
while True:
code = input("Enter Item Code (or type DONE to finish): ").strip()
if code.upper() == "DONE":
break
if code not in menu:
print("Invalid Item Code. Try again.")
continue
qty_str = input("Enter Quantity: ").strip()
if not qty_str.isdigit():
print("Quantity must be a number.")
continue
qty = int(qty_str)
if qty <= 0:
print("Quantity must be >= 1.")
continue
if code in cart:
cart[code] = cart[code] + qty
else:
cart[code] = qty
if len(cart) == 0:
print("No items selected. Order cancelled.")
return
# Calculate bill
total = 0.0
items_parts = []
print("\n--- BILL ---")
for code in cart:
name = menu[code][0]
price = menu[code][1]
qty = cart[code]
amount = price * qty
total = total + amount
print(code + " " + name + " x " + str(qty) + " = " + str(amount))
# store items as code:qty for saving in file
items_parts.append(code + ":" + str(qty))
order_no = get_next_order_number()
date_str = get_today_date_str()
bill_id = date_str.replace("-", "") + "-" + str(order_no) # unique id: date + order no
print("Order Number: " + str(order_no))
print("Bill ID: " + bill_id)
print("TOTAL = " + str(total))
print("-----------\n")
items_text = ",".join(items_parts)
append_bill_line(bill_id, date_str, order_no, items_text, total)
print("Bill saved successfully (soft copy stored in bills.txt).")
# ----------------------------
# Manager section
# ----------------------------
def manager_menu():
menu = load_menu()
while True:
print("\n--- MANAGER OPTIONS ---")
print("1) View Menu")
print("2) Add Menu Item")
print("3) Update Menu Item")
print("4) Delete Menu Item")
print("5) Delete Order (by Bill ID)")
print("6) Sales Summary Report (by Date)")
print("7) Extra Report: Most Sold Item (by Date)")
print("0) Logout")
choice = input("Enter choice: ").strip()
if choice == "1":
display_menu(menu)
elif choice == "2":
code = input("Enter new Item Code: ").strip()
if code in menu:
print("Item code already exists.")
continue
name = input("Enter Item Name: ").strip()
price_str = input("Enter Price: ").strip()
try:
price = float(price_str)
except:
print("Invalid price.")
continue
menu[code] = (name, price)
save_menu(menu)
print("Item added.")
elif choice == "3":
code = input("Enter Item Code to update: ").strip()
if code not in menu:
print("Item code not found.")
continue
name = input("Enter new Name: ").strip()
price_str = input("Enter new Price: ").strip()
try:
price = float(price_str)
except:
print("Invalid price.")
continue
menu[code] = (name, price)
save_menu(menu)
print("Item updated.")
elif choice == "4":
code = input("Enter Item Code to delete: ").strip()
if code not in menu:
print("Item code not found.")
continue
del menu[code]
save_menu(menu)
print("Item deleted.")
elif choice == "5":
bill_id = input("Enter Bill ID to delete: ").strip()
lines = read_all_bills()
new_lines = []
found = False
for line in lines:
if line.split("|")[0] == bill_id:
found = True
else:
new_lines.append(line)
write_all_bills(new_lines)
if found:
print("Order deleted.")
else:
print("Bill ID not found.")
elif choice == "6":
date_str = input("Enter date (YYYY-MM-DD): ").strip()
lines = read_all_bills()
total_sales = 0.0
total_orders = 0
for line in lines:
parts = line.split("|")
b_date = parts[1]
b_total = float(parts[4])
if b_date == date_str:
total_orders = total_orders + 1
total_sales = total_sales + b_total
print("\n--- SALES SUMMARY for " + date_str + " ---")
print("Total Orders: " + str(total_orders))
print("Total Sales : " + str(total_sales))
print("-----------------------------------")
elif choice == "7":
# Extra report: Most sold item (by quantity) on a given date
date_str = input("Enter date (YYYY-MM-DD): ").strip()
lines = read_all_bills()
qty_map = {} # code -> total qty
for line in lines:
parts = line.split("|")
b_date = parts[1]
items_text = parts[3]
if b_date == date_str:
items = items_text.split(",")
for it in items:
p = it.split(":")
code = p[0]
qty = int(p[1])
if code in qty_map:
qty_map[code] = qty_map[code] + qty
else:
qty_map[code] = qty
if len(qty_map) == 0:
print("No orders found for this date.")
else:
# find max
max_code = None
max_qty = -1
for code in qty_map:
if qty_map[code] > max_qty:
max_qty = qty_map[code]
max_code = code
item_name = "Unknown"
if max_code in menu:
item_name = menu[max_code][0]
print("\n--- MOST SOLD ITEM for " + date_str + " ---")
print("Item Code: " + max_code)
print("Item Name: " + item_name)
print("Quantity : " + str(max_qty))
print("-----------------------------------")
elif choice == "0":
print("Logging out...")
break
else:
print("Invalid choice.")
def main_restaurant_app():
while True:
print("\n===== STAY HEALTHY RESTAURANT SYSTEM =====")
print("1) Customer Login")
print("2) Manager Login")
print("0) Exit")
choice = input("Enter choice: ").strip()
if choice == "1":
customer_place_order()
elif choice == "2":
pwd = input("Enter manager password: ").strip()
# Simple password for learning purpose
if pwd == "admin123":
manager_menu()
else:
print("Wrong password.")
elif choice == "0":
print("Thank you. Bye!")
break
else:
print("Invalid choice.")
# Run the program
main_restaurant_app()
Sample Output (example run)
===== STAY HEALTHY RESTAURANT SYSTEM =====
1) Customer Login
2) Manager Login
0) Exit
Enter choice: 1
--- MENU ---
Code Name Price
I101 Salad 120.0
I102 Soup 90.0
I103 Sandwich 150.0
I104 Juice 80.0
------------
Enter Item Code (or type DONE to finish): I101
Enter Quantity: 2
Enter Item Code (or type DONE to finish): I104
Enter Quantity: 1
Enter Item Code (or type DONE to finish): DONE
--- BILL ---
I101 Salad x 2 = 240.0
I104 Juice x 1 = 80.0
Order Number: 1
Bill ID: 20260209-1
TOTAL = 320.0
-----------
Bill saved successfully (soft copy stored in bills.txt).
Project 2
Project Title 2: Development of a Puzzle.
Description:
Implement a puzzle solving game in Python. The game presents a grid board composed of cells to the player, in which some cells have Bomb. Player is required to clear the board (of the bomb), without detonating any one of them with the help of clue(s) provided on the board.
Specifications:
For clearing the board, the player will click a cell on the board; if the cell contains a bomb, the game finishes. If the cell does not contain a bomb, then the cell reveals a number giving a clue about the number of bombs hidden in adjacent cells.
Before you start coding the game, play any Minesweeper game five times. This will help you in proper understanding of your project. To reduce the complexity of the program you can fix the grid size to 6×6 and number of bombs to 6.
Note: Do ensure to handle various exception(s) which may occur while playing the game, in your code.
Answer 2
✅ Python Program (Text-based Minesweeper + log file)
Files used:
minesweeper_log.txt, minesweeper_best.txt (plain text)import random
import os
from datetime import datetime
LOG_FILE = "minesweeper_log.txt"
BEST_FILE = "minesweeper_best.txt"
ROWS = 6
COLS = 6
BOMBS = 6
def create_board(rows, cols, fill):
board = []
for r in range(rows):
row = []
for c in range(cols):
row.append(fill)
board.append(row)
return board
def place_bombs(rows, cols, bombs):
# Store bomb positions in a set for quick checking
bomb_set = set()
while len(bomb_set) < bombs:
r = random.randint(0, rows - 1)
c = random.randint(0, cols - 1)
bomb_set.add((r, c))
return bomb_set
def count_adjacent_bombs(r, c, bomb_set):
count = 0
for dr in [-1, 0, 1]:
for dc in [-1, 0, 1]:
if dr == 0 and dc == 0:
continue
nr = r + dr
nc = c + dc
if 0 <= nr < ROWS and 0 <= nc < COLS:
if (nr, nc) in bomb_set:
count = count + 1
return count
def display_visible(visible):
print("\n 1 2 3 4 5 6")
print(" -------------")
for r in range(ROWS):
line = str(r + 1) + "| "
for c in range(COLS):
line = line + str(visible[r][c]) + " "
print(line)
print(" -------------")
def save_log(result, moves):
# Save game result in a log file
dt = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
f = open(LOG_FILE, "a")
f.write(dt + " | " + result + " | moves=" + str(moves) + "\n")
f.close()
def load_best_moves():
if not os.path.exists(BEST_FILE):
return None
f = open(BEST_FILE, "r")
data = f.read().strip()
f.close()
if data == "":
return None
return int(data)
def save_best_moves(moves):
f = open(BEST_FILE, "w")
f.write(str(moves))
f.close()
def minesweeper_game():
bomb_set = place_bombs(ROWS, COLS, BOMBS)
visible = create_board(ROWS, COLS, "#") # hidden cells
opened = set()
moves = 0
safe_cells = ROWS * COLS - BOMBS
print("Minesweeper (6x6) started. Bombs = 6")
print("Enter row and column (1 to 6). Example: 2 4")
while True:
display_visible(visible)
user_in = input("Enter row col (or type EXIT): ").strip()
if user_in.upper() == "EXIT":
print("Game ended by user.")
save_log("EXIT", moves)
break
parts = user_in.split()
if len(parts) != 2:
print("Invalid input. Please enter two numbers like: 2 4")
continue
if (not parts[0].isdigit()) or (not parts[1].isdigit()):
print("Row and column must be numbers.")
continue
r = int(parts[0]) - 1
c = int(parts[1]) - 1
# Exception handling for range
if r < 0 or r >= ROWS or c < 0 or c >= COLS:
print("Out of range. Enter values from 1 to 6.")
continue
if (r, c) in opened:
print("This cell is already opened.")
continue
moves = moves + 1
opened.add((r, c))
if (r, c) in bomb_set:
visible[r][c] = "B"
display_visible(visible)
print("Boom! You clicked a bomb. Game Over.")
save_log("LOSE", moves)
break
else:
clue = count_adjacent_bombs(r, c, bomb_set)
visible[r][c] = str(clue)
# Win check: opened safe cells
if len(opened) == safe_cells:
display_visible(visible)
print("Congratulations! You cleared the board safely.")
save_log("WIN", moves)
best = load_best_moves()
if best is None or moves < best:
save_best_moves(moves)
print("New best score (least moves): " + str(moves))
else:
print("Best score (least moves) is: " + str(best))
break
# Run the game
minesweeper_game()
Sample Output (example)
Minesweeper (6x6) started. Bombs = 6
Enter row and column (1 to 6). Example: 2 4
1 2 3 4 5 6
-------------
1| # # # # # #
2| # # # # # #
3| # # # # # #
4| # # # # # #
5| # # # # # #
6| # # # # # #
-------------
Enter row col (or type EXIT): 2 4
1 2 3 4 5 6
-------------
1| # # # # # #
2| # # # 1 # #
3| # # # # # #
4| # # # # # #
5| # # # # # #
6| # # # # # #
-------------
Enter row col (or type EXIT): 6 6
Boom! You clicked a bomb. Game Over.
Project 3
Project Title 3: Development of an Educational Game.
Description:
You are a member of the ICT club of your school. As a club member, you are given the responsibility of identifying ways to improve mathematical skills of kids, in the age group of 5-7 years. One of the club members suggested developing an Edutainment Game named “Match the Sum” for it. Match the Sum will hone summing skills of student(s), by allowing them to form number 10 by adding 2/3 digits.
Specifications:
Following are the details of provisions required for program:
•
Display a list of 15 cells on screen, where each cell can hold a digit (1 to 9).
•
Randomly generate a digit at a time and place it in the list from the right end. Program will keep on generating digits at equal intervals of time and place it in the rightmost cell. (Already existing digits will be shifted left by one cell with every new addition of digits in the list).
•
For playing the game, students will be allowed to type 2/3 digits (one at a time) currently displayed in the list of cells.
•
If the sum of those digits is 10, then those digits should get removed from the list of cells.
•
Game will continue till there is an empty cell to insert a digit in the list of cells.
Answer 3
✅ Python Program (Match the Sum + score file)
File used:
match_sum_scores.txt (plain text)import random
from datetime import datetime
import os
SCORE_FILE = "match_sum_scores.txt"
def display_cells(cells):
# Show 15 cells with positions
print("\nCells:")
line_pos = ""
line_val = ""
i = 1
while i <= 15:
line_pos = line_pos + str(i).rjust(2) + " "
i = i + 1
i = 0
while i < 15:
val = cells[i]
if val == "":
val = "."
line_val = line_val + str(val).rjust(2) + " "
i = i + 1
print(line_pos)
print(line_val)
def shift_left_one_step(cells):
# Shift digits left by ONE step into empty space (simple and matches "shift left by one cell")
i = 0
while i < 14:
if cells[i] == "" and cells[i + 1] != "":
cells[i] = cells[i + 1]
cells[i + 1] = ""
i = i + 1
def has_empty_cell(cells):
i = 0
while i < 15:
if cells[i] == "":
return True
i = i + 1
return False
def insert_new_digit(cells):
# First do a left shift by one step (as per requirement)
shift_left_one_step(cells)
# Insert new digit in the rightmost cell IF it is empty
if cells[14] != "":
return False # cannot insert, game ends
d = random.randint(1, 9)
cells[14] = str(d)
return True
def save_score(removed_count, turns):
dt = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
f = open(SCORE_FILE, "a")
f.write(dt + " | removed=" + str(removed_count) + " | turns=" + str(turns) + "\n")
f.close()
def match_sum_game():
cells = [""] * 15
removed_count = 0
turns = 0
print("Match the Sum Game started (Goal: make sum = 10 using 2 or 3 digits)")
print("Rules: digits appear on right side, digits shift left, you pick positions to remove if sum is 10.")
while True:
# If no empty, we cannot insert a digit -> game ends
if not has_empty_cell(cells) and cells[14] != "":
print("\nNo empty cell to insert a digit. Game Over.")
break
input("\nPress Enter to generate next digit...") # simulates time interval
ok = insert_new_digit(cells)
turns = turns + 1
if not ok:
print("\nNo empty cell to insert a digit. Game Over.")
break
display_cells(cells)
choice = input("Enter 2 or 3 positions separated by space (or type SKIP): ").strip()
if choice.upper() == "SKIP":
continue
parts = choice.split()
if len(parts) != 2 and len(parts) != 3:
print("Please enter exactly 2 or 3 positions.")
continue
# Validate positions and calculate sum
pos_list = []
valid = True
for p in parts:
if not p.isdigit():
valid = False
break
pos = int(p)
if pos < 1 or pos > 15:
valid = False
break
pos_list.append(pos - 1)
if not valid:
print("Invalid positions. Use numbers from 1 to 15.")
continue
# Check if those cells have digits
total = 0
for idx in pos_list:
if cells[idx] == "":
print("One selected cell is empty. Try again.")
valid = False
break
total = total + int(cells[idx])
if not valid:
continue
if total == 10:
# Remove those digits (make cells empty)
for idx in pos_list:
cells[idx] = ""
removed_count = removed_count + len(pos_list)
print("Correct! Sum is 10. Digits removed.")
else:
print("Sum is " + str(total) + ". Not equal to 10, so nothing removed.")
save_score(removed_count, turns)
print("\nYour score saved in match_sum_scores.txt")
print("Total digits removed: " + str(removed_count))
print("Total turns: " + str(turns))
# Run the game
match_sum_game()
Sample Output (example run)
Match the Sum Game started (Goal: make sum = 10 using 2 or 3 digits)
Rules: digits appear on right side, digits shift left, you pick positions to remove if sum is 10.
Press Enter to generate next digit...
Cells:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
. . . . . . . . . . . . . . 7
Enter 2 or 3 positions separated by space (or type SKIP): SKIP
Press Enter to generate next digit...
Cells:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
. . . . . . . . . . . . . 7 3
Enter 2 or 3 positions separated by space (or type SKIP): 14 15
Correct! Sum is 10. Digits removed.