Python CBP
Python CBP
CANTEEN BILL
submitted
for
I year CSE-D
Of
VNRVJIET
by
1.P.ABHISHEK -22071A05T1
2.S.DIVYA SRI -22071A05R3
3.V.VARAPRASAD -22071A05T3
4.Y.SRI VAISHNAVI -22071A05T4
2022-23
1
A Project Report On
CANTEEN BILL
submitted
in
Of
VNRVJIET
2022-2023
2
VNR Vignana Jyothi Institute of Engineering and Technology
Department of CSE
This is to certify that the project entitled “CANTEEN BILL” submitted in partial
fulfilment for the course of Python Laboratory being offered for the award of
B.Tech (Computer Science and Engineering) by VNR VJIET is a result of the
bonafide work carried out by 22071A05Q2,22071A05R3,22071A05T3
and 22071A05T4 during the year 2022-2023. This has not been submitted
for any other certificate or course.
3
ACKNOWLEDGEMENT
4
DECLARATION
We hereby declare that this Project Report titled “CANTEEN BILL” submitted
by us of Computer Science & Engineering in VNR Vignana Jyothi Institute of
Engineering and Technology, is a bonafide work under taken by us and it is
not submitted for any other certificate /Course or published any time before.
22071A05P0 – P. Abhishek
22071A05T3 – V.Varaprasad
5
INDEX
3 IMPLEMENTATION 9-12
4 RESULTS 13-14
5 APPLICATIONS 15-16
6 REFERENCES 16
6
ABSTRACT
7
INTRODUCTION
8
IMPLEMENTATION OF CANTEEN BILL:
# menu.py
MENU = {
'1': {'name': 'Burger', 'price': 3.50},
'2': {'name': 'Pizza', 'price': 4.00},
'3': {'name': 'Pasta', 'price': 2.50},
'4': {'name': 'Sandwich', 'price': 2.00},
'5': {'name': 'French Fries', 'price': 1.50},
}
def display_menu():
print("Menu:")
print("Item ID\t\tItem Name\t\tPrice")
print("----------------------------------------")
for item_id, item_info in MENU.items():
print(f"{item_id}\t\t{item_info['name']}\t\t${item_info['price']}")
print("----------------------------------------")
# canteen.py
def calculate_total(items):
total = 0
for item in items:
total += item['price'] * item['quantity']
return total
def canteen_bill():
items = []
while True:
display_menu()
item_id = input("Enter item ID (or 'q' to quit): ")
if item_id == 'q':
break
item_info = MENU.get(item_id)
if not item_info:
print("Invalid item ID. Please select a valid item.")
continue
item = {
'name': item_info['name'],
'price': item_info['price'],
'quantity': quantity
}
items.append(item)
10
total = calculate_total(items)
print_bill_to_file(items, total, "canteen_bill.txt")
print("Bill saved to canteen_bill.txt.")
print("\nPresent Bill:")
print_present_bill(items, total)
while True:
print_all_bills = input("Do you want to print all bills? (y/n): ").lower()
if print_all_bills == 'y':
with open("canteen_bill.txt", 'r') as file:
print(file.read())
break
elif print_all_bills == 'n':
break
else:
print("Invalid input. Please enter 'y' or 'n'.")
if __name__ == "__main__":
canteen_bill()
menu.py Module:
1. Purpose: This module is responsible for managing the menu items and displaying them
to the user.
2. Components:
- MENU Dictionary: This dictionary holds the information about menu items, where each
item is associated with a unique ID. It contains item names and prices.
- display_menu() Function: This function displays the menu items with their IDs, names,
and prices in a structured format.
3. Functionality: The module's primary functionality is to present the available food items
to the user. It encapsulates the menu-related data and display logic, promoting code
reusability and maintaining a clear separation of concerns.
11
4. Concepts Demonstrated:
- Modularization: The module isolates menu-related functionality from the main billing
logic.
- Dictionary: The `MENU` dictionary stores menu items with IDs and their respective
details.
- Function: The `display_menu()` function encapsulates the code for displaying the menu.
canteen.py Module:
1. Purpose: This module constitutes the core of the canteen billing system, handling user
interactions, order placement, bill calculation, and bill storage.
2. Components:
- calculate_total(items) Function: Calculates the total cost of ordered items based on
their prices and quantities.
- print_bill_to_file(items, total, filename) Function: Writes the generated bill details to
a text file.
- canteen_bill() Function: This is the main function that orchestrates the entire billing
process. It interacts with users, processes orders, calculates bills, and saves the bill to a
file.
- if __name__ == "__main__": Block: Ensures that the `canteen_bill()` function is
executed when the script is run directly.
4. Concepts Demonstrated:
- Function: Multiple functions are defined to manage different aspects of the billing
process.
- User Input/Output: The functions interact with users by displaying prompts and
receiving input.
- File Handling: The `print_bill_to_file()` function demonstrates reading/writing
operations with external files.
- Conditional Statements : Control the flow of the program based on user input.
- Modular Programming: The module's functions encapsulate specific tasks, promoting
code organization and reusability.
Both modules work in tandem to create a comprehensive canteen billing system. The
separation of concerns between menu-related operations (`menu.py`) and billing
operations (`canteen.py`) exemplifies effective modular programming, promoting clarity
and maintainability.
12
RESULTS:
Menu:
Item ID Item Name Price
----------------------------------------
1 Burger $3.5
2 Pizza $4.0
3 Pasta $2.5
4 Sandwich $2.0
5 French Fries $1.5
----------------------------------------
Enter item ID (or 'q' to quit): 1
Enter item quantity: 6
Menu:
Item ID Item Name Price
----------------------------------------
1 Burger $3.5
2 Pizza $4.0
3 Pasta $2.5
4 Sandwich $2.0
5 French Fries $1.5
----------------------------------------
Enter item ID (or 'q' to quit): 8
Invalid item ID. Please select a valid item.
Menu:
Item ID Item Name Price
----------------------------------------
1 Burger $3.5
2 Pizza $4.0
3 Pasta $2.5
4 Sandwich $2.0
5 French Fries $1.5
----------------------------------------
Enter item ID (or 'q' to quit): 5
Enter item quantity: 3
Menu:
Item ID Item Name Price
----------------------------------------
1 Burger $3.5
2 Pizza $4.0
3 Pasta $2.5
4 Sandwich $2.0
5 French Fries $1.5
----------------------------------------
Enter item ID (or 'q' to quit): 2
13
Enter item quantity: 9
Menu:
Item ID Item Name Price
----------------------------------------
1 Burger $3.5
2 Pizza $4.0
3 Pasta $2.5
4 Sandwich $2.0
5 French Fries $1.5
----------------------------------------
Enter item ID (or 'q' to quit): 4
Enter item quantity: 5
Menu:
Item ID Item Name Price
----------------------------------------
1 Burger $3.5
2 Pizza $4.0
3 Pasta $2.5
4 Sandwich $2.0
5 French Fries $1.5
----------------------------------------
Enter item ID (or 'q' to quit): q
Bill saved to canteen_bill.txt.
Present Bill:
************* Canteen Bill *************
Item Quantity Price
----------------------------------------
Burger 6 21.0
French Fries 3 4.5
Pizza 9 36.0
Sandwich 5 10.0
----------------------------------------
Total: 71.5
***************************************
Do you want to print all bills? (y/n): y
************* Canteen Bill *************
Item Quantity Price
----------------------------------------
Burger 6 21.0
French Fries 3 4.5
Pizza 9 36.0
Sandwich 5 10.0
----------------------------------------
Total: 71.5
***************************************
14
APPLICATIONS:
The Canteen Billing System project has several practical applications that extend beyond
its immediate implementation. Here are a few potential applications:
4. Event Catering:
- Event catering services can utilize this system to efficiently manage orders and
generate bills during conferences, parties, and gatherings. It helps catering teams
accurately account for the ordered food and its cost.
5. Educational Institutions:
- School and college cafeterias can implement this system to facilitate the billing process
for students and staff. It can be customized to incorporate meal plans and discounts.
6. Employee Cafeterias:
- In workplaces with employee cafeterias, the system can be used to manage meal
orders, calculate bills, and maintain records. It aids in maintaining transparency in billing.
9. Self-Service Kiosks:
15
- Restaurants and eateries with self-service kiosks can use this system to automate the
order placement and billing processes.
In essence, the Canteen Billing System showcases the potential of using programming to
optimize everyday processes, making them more efficient, accurate, and user-friendly
across various industries.
REFERENCES:
https://www.geeksforgeeks.org/
Tutorials And Articles (tutorialspoint.com)
16