https://github.com/mateuszcalderon/receipt
An easy receipt code made with Python to improve my programming skills.
https://github.com/mateuszcalderon/receipt
programming python
Last synced: 9 months ago
JSON representation
An easy receipt code made with Python to improve my programming skills.
- Host: GitHub
- URL: https://github.com/mateuszcalderon/receipt
- Owner: mateuszcalderon
- License: mit
- Created: 2024-03-18T12:42:30.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2025-01-29T01:20:27.000Z (11 months ago)
- Last Synced: 2025-02-08T03:34:43.682Z (11 months ago)
- Topics: programming, python
- Language: Python
- Homepage:
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Receipt
This is my very first Python project where I created a simple receipt generator that calculates the total cost for a product purchase, including tax. The program prompts the user for the product's price, name, and quantity, then displays a neatly formatted receipt with the current date and time.
#### Key Features:
- **Real-time Date and Time:** The receipt displays the current date and time, formatted to resemble an actual receipt.
- **Tax Calculation:** The program calculates a 7.125% tax on the subtotal and displays the tax amount separately.
- **Formatted Output:** The receipt is formatted to look professional, showing the product, quantity, subtotal, tax, and total with proper decimal precision.
- **User Input:** The user can input the product's price, name, and quantity, and the program will calculate the total cost.
## Code Walkthrough:
#### Library:
```python
import datetime
```
- ` datetime `: Used to fetch the current date and time.
#### Collecting User Input:
```python
product_price = float(input("PRICE: "))
product_name = input("PRODUCT: ")
quantity = int(input("QTY: "))
```
- The user is prompted to enter the product's price, name, and quantity. The price is converted to float, and the quantity is converted to integer.
#### Displaying the Receipt:
```python
print("---------------------------")
print(" RECEIPT ")
print(current_time.strftime("%m/%d/%Y.........%H:%M:%S"))
print(f"PRODUCT : {product_name.upper()}")
print(f"QTY : {quantity}")
```
- The program prints the formatted receipt header and uses ` strftime ` to display the current date and time in a receipt-like format. The product name is also converted to uppercase to enhance the receipt’s appearance.
#### Calculating the Subtotal, Tax, and Total:
```python
sub_total = product_price * quantity
tax = 7.125 / 100 * sub_total
total = tax + sub_total
```
- The program calculates the subtotal, tax amount, and total cost by applying a 7.125% tax rate to the subtotal.
#### Final Output:
```python
print(f"SUB TOTAL : {sub_total:.2f}")
print(f"TAX AMOUNT: ${tax:.2f}")
print(f"TOTAL : ${total:.2f}")
print("---------------------------")
```
- The receipt is displayed with the product details, calculated subtotal, tax amount, and total. All amounts are formatted to two decimal places for clarity.
## Development Environment:
To develop this project, I used the online IDE [OnlineGDB.com](https://www.onlinegdb.com/online_python_compiler), which offers an easy-to-use compiler and debugger for Python.
## Contact:
Feel free to reach out to me with any questions, suggestions, or feedback!
[](https://github.com/mateuszcalderon)
[](https://www.instagram.com/mateuszcalderon/)
[](https://www.linkedin.com/in/mateuszcalderonreis/)