0% found this document useful (0 votes)
11 views10 pages

Python Shop Billing and Tax Systems

Python notes

Uploaded by

hero60637
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views10 pages

Python Shop Billing and Tax Systems

Python notes

Uploaded by

hero60637
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Term Work- S2418305

1. Title/Aim
Program to Implement a Shop Billing System in Python
2. Objective
To create a simple shop billing system in Python where user can enter
item details (name, quantity, price) and generate the final bill.
3. Theory
In Python, lists and loops can be used to create a simple billing system.
Steps:
1. User enters number of items.
2. For each item, input name, quantity, and price.
3. Calculate total cost for each item (quantity × price).
4. Store the details in a list.
5. Print the bill in tabular format.
6. Display the grand total.
4. Algorithm
1. Start
2. Read the number of items from the user.
3. For each item:
Input name, quantity, and price.
Calculate total = quantity × price.
Store in a list.
4. Initialize grand_total = 0.
5. Display bill in tabular format.
6. Add each item’s total to grand_total.
7. Print grand_total.
8. Stop.
5. Python Program
# Shop Billing System in Python
n = int(input("Enter number of items: "))
items = []
for i in range(n):
name = input("Enter item name: ")
qty = int(input("Enter quantity: "))
price = float(input("Enter price: "))
total = qty * price
[Link]([name, qty, price, total])
print("\n------ BILL ------")
print("{:<10}{:<10}{:<10}{:<10}".format("Item", "Qty", "Price", "Total"))
grand_total = 0
for item in items:
print("{:<10}{:<10}{:<10}{:<10}".format(item[0], item[1], item[2], item[3]))
grand_total += item[3]
print("------------------")
print("Grand Total = Rs.", grand_total)
6. Sample Output
Enter number of items: 2
Enter item name: Pen
Enter quantity: 10
Enter price: 5
Enter item name: Notebook
Enter quantity: 2
Enter price: 50
------ BILL ------
Item Qty Price Total
Pen 10 5.0 50.0
Notebook 2 50.0 100.0
Grand Total = Rs. 150.0
7. Conclusion
The shop billing system in Python was successfully implemented.
It accepts item details, calculates total, and generates the final bill.
1. Title
Program to Implement an Income Tax Calculation System in Python
2. Objective
To calculate income tax of a person based on the given annual income
using Python programming.
3. Theory
Income tax is the tax levied by the government on a person's annual income.
In this program, conditional statements (if-elif-else) in Python are used
to calculate the tax as per defined slabs.
Example slab (for demonstration purpose):
- Income up to 2,50,000 : No tax
- Income 2,50,001 – 5,00,000 : 5%
- Income 5,00,001 – 10,00,000 : 20%
- Above 10,00,000 : 30%
4. Algorithm
1. Start
2. Read annual income from the user.
3. Initialize tax = 0.
4. Check conditions:
If income ≤ 2,50,000 → tax = 0
Else if income ≤ 5,00,000 → tax = 5% of (income – 2,50,000)
Else if income ≤ 10,00,000 → tax = 12,500 + 20% of (income – 5,00,000)
Else → tax = 1,12,500 + 30% of (income – 10,00,000)
5. Print tax amount.
6. Stop.
5. Python Program
# Income Tax Calculation System in Python
income = float(input("Enter your annual income: "))
if income <= 250000:
tax = 0
elif income <= 500000:
tax = (income - 250000) * 0.05
elif income <= 1000000:
tax = 12500 + (income - 500000) * 0.20
else:
tax = 112500 + (income - 1000000) * 0.30
print("Your annual income: Rs.", income)
print("Income Tax Payable: Rs.", tax)
6. Sample Output
Enter your annual income: 750000
Your annual income: Rs. 750000.0
Income Tax Payable: Rs. 62500.0
7. Conclusion
The income tax calculation system in Python was successfully implemented.
The program accepts annual income, applies slab rates, and displays the tax
payable.
1. Title/Aim
Program to Convert a Word into Number by Assigning a=1, b=2, … z=26

2. Objective
To write a Python program that converts a given word into a number by
adding the numeric values of its alphabets (a=1 to z=26).

3. Theory
Every alphabet in English can be mapped to a number:
a=1, b=2, c=3 … z=26.
The program:
1. Accepts a word from the user.
2. Converts each character into its numeric value.
3. Adds all values to get the final result.
In Python, the ord() function is used to get ASCII values.
For lowercase: ord('a') = 97, so value = ord(char) - 96.

4. Algorithm
1. Start
2. Input a word from the user.
3. Initialize total = 0.
4. For each character in the word:
Convert to lowercase.
Find its value using ord(ch) - 96.
Add value to total.
5. Display the total.
6. Stop.
5. Python Program
# Word to Number Conversion (a=1, b=2, ... z=26)
word = input("Enter a word: ").lower()
total = 0
for ch in word:
if 'a' <= ch <= 'z': # check only alphabets
total += (ord(ch) - 96)
print("Word:", word)
print("Numeric Value:", total)
6. Sample Output
Enter a word: chatgpt
Word: chatgpt
Numeric Value: 79
(Explanation: c=3, h=8, a=1, t=20, g=7, p=16, t=20 → total = 79)
7. Conclusion
The program was successfully implemented in Python.
It converts a word into a number by assigning values to alphabets (a=1 to z=26)
and summing them up.
Seminar Report / Term Work
Python Date/Time Module and Its Applications
1. Title
Python Date/Time Module and Its Applications
2. Objective
To study the Date/Time module in Python and understand how to use it
for handling dates, times, and related operations in real-life applications.
3. Theory
Python provides a built-in module called "datetime" which is used to work
with dates and times. It allows us to perform operations such as:
- Getting current date and time
- Formatting dates and times
- Doing arithmetic with dates (add/subtract days, hours, etc.)
- Extracting day, month, year, hour, minute, second
Important classes in datetime module:
1. date → Deals with dates (year, month, day)
2. time → Deals with time (hour, minute, second, microsecond)
3. datetime → Combination of date and time
4. timedelta → Represents duration (difference between two dates/times)
4. Applications
1. Calendar applications → scheduling, reminders
2. Attendance systems → storing login/logout time
3. Banking systems → calculating interest based on dates
4. Event management → countdowns, deadlines, alarms
5. E-commerce websites → order date, delivery date calculation
6. Data analysis → timestamping data, log files
5. Sample Python Programs
👉 Example 1: Display Current Date and Time
import datetime
now = [Link]()
print("Current Date and Time:", now)
👉 Example 2: Extract Components
import datetime
now = [Link]()
print("Year:", [Link])
print("Month:", [Link])
print("Day:", [Link])
print("Hour:", [Link])
print("Minute:", [Link])
👉 Example 3: Date Arithmetic
import datetime
today = [Link]()
new_date = today + [Link](days=10)
print("Today:", today)
print("After 10 days:", new_date)
6. Sample Output
Current Date and Time: 2025-10-13 14:25:30.512345
Year: 2025
Month: 10
Day: 13
Hour: 14
Minute: 25
Today: 2025-10-13
After 10 days: 2025-10-23
7. Conclusion
The datetime module in Python is very powerful and essential
for real-world applications where date and time handling is required.
It provides simple and efficient ways to work with time, scheduling,
event tracking, and data analysis.

Common questions

Powered by AI

Python's datetime module facilitates date arithmetic operations through the use of the 'timedelta' class. This class represents the duration (difference between two dates or times), allowing users to add or subtract days, hours, minutes, etc., from a given date or time . In real-world applications, this feature is crucial for calendar applications (e.g., reminders, scheduling), event management (e.g., countdowns, deadlines), and e-commerce sites for calculating delivery dates .

To implement a shop billing system in Python, the key steps involve reading the number of items, and for each item, inputting its name, quantity, and price. Lists are used to store the item details, and loops iterate over the list to calculate the total for each item by multiplying quantity by price. The loop also helps print the bill in a tabular format and calculate the grand total by summing all individual totals .

The datetime module's ability to extract components like year, month, and day enhances data handling and analysis by allowing for precise manipulation and formatting of dates. This feature is particularly useful in applications requiring detailed date analysis, such as tracking yearly trends, scheduling, and timestamping. By enabling the extraction of specific date parts, developers can tailor date-based operations to fit specific analytical or business requirements .

Python's datetime module supports the development of an attendance system by providing functions to log precise entry and exit times. The datetime class can be used to capture the current time upon an employee's entry and exit, while timedelta enables calculations of the total duration of attendance. This capability allows for accurate tracking of attendance records, which is critical in systems requiring precise time audits and workforce management .

In the word to number converter program, the ord() function is significant as it returns the ASCII value of a character. For lowercase alphabets, the ASCII value of 'a' is 97, so to map 'a' to 1, the program subtracts 96 from the ASCII value of the character. By iterating through each character in the word, converting it to its numeric equivalent via this method, and summing these values, the program derives the word's total numeric value .

Using Python for implementing an income tax calculation system offers several benefits, including its simplicity and readability, which make the code easy to understand and maintain. Python's robust standard library, like datetime for handling financial years and simple arithmetic operations, is valuable for tax calculations. Additionally, Python's large community provides ample resources and libraries that can facilitate building complex systems efficiently compared to some statically-typed languages that might require more verbose and complex implementations .

Implementing a shop billing system in Python for a real-world business may pose several challenges, such as handling a large inventory efficiently, managing user errors during input, and integrating additional features like tax calculations or discounts. These challenges could be addressed by using data structures like dictionaries or databases to handle inventory, incorporate error-checking mechanisms to validate user inputs, and design the program modularly to easily integrate additional features .

The income tax calculation program in Python uses conditional statements (if-elif-else) to determine the tax slab for a given annual income. For incomes up to Rs. 2,50,000, the tax is zero. For incomes between Rs. 2,50,001 and Rs. 5,00,000, the tax is 5% of the amount exceeding Rs. 2,50,000. For incomes between Rs. 5,00,001 and Rs. 10,00,000, the tax is Rs. 12,500 plus 20% of the amount exceeding Rs. 5,00,000. For incomes above Rs. 10,00,000, the tax is Rs. 1,12,500 plus 30% of the amount exceeding Rs. 10,00,000 .

To enhance the Python program to convert words into numbers and handle non-alphabetic characters or case sensitivity, one could implement a filter to ignore non-alphabetic characters during the conversion process. Additionally, using the .lower() method ensures case insensitivity by converting all characters to lowercase before conversion. This approach maintains the program's functionality by focusing conversion only on valid alphabetic characters .

Using a Python list to store item details in a shop billing system offers the benefit of simplicity and ease of use. Lists allow for straightforward addition and iteration over item entries. However, the limitation lies in the lack of structure for complex applications, as lists are not optimal for handling large datasets or when additional item attributes need efficient retrieval. For more organized data structures, lists could be replaced by dictionaries or data classes, which provide better data management and access capabilities .

You might also like