Introduction
This project is an exercise in formatting with f-strings.
The Tale
You are working for a "parts" company in their IT department.
Your boss wants you to generate an invoice to be included
in every box shipped to a customer.
Project #1
Format and print an invoice using f-strings.
See the example found
HERE .
Add at least 8 more products to the list (warehouse inventory)
shown below1.
Randomly pick a minimum of 6 products from the list (warehouse inventory)
for the invoice.
Print the invoice. (This will require a mono space font.)
Requirements/Design/Business-Rules
- a box of parts may contain up to 20 items
- if there are over 20 items, a second, third, ...
box invoice is created
- the company address will be stored in a list1
(this simulates reading it from a database)
- there is 6% sales tax on the order
- taxes are rounded to the nearest penny
- if the total cost of the order (minus any taxes) is over $100,
shipping is free
otherwise there is a 10% charge for shipping
- the customer address will be stored in a list1
(this simulates reading it from a database)
- the items will be stored in a list1 of lists
(each product is a list within the items list1
this simulates reading them from a database)
- The invoice date is the current date
1see the Inputs below.
Project #2
Create a program that allows the user to select the items to
purchase. Generate the box invoices for the items to ship.
(Perhaps a GUI?)
Project #3
a. save the minimum invoice information in a JSON file.
b. read the invoice information from a JSON file.
c. recreate the original invoice(s).
Inputs
customerid = '00054619'
invoiceid = '00001'
from = ['ABC Parts Company',
'Dept 001',
'2121 Parts Rd',
'Parts, OH 91234' ]
to = ['Flying Machines',
'120 Airport Ave',
'Billings, MT 78912' ]
Warehouse inventory
# product id, description, unit-cost, quantity on hand
items = [
[841, 'Flux Capacitor', 123.47, 3],
[32, 'Glow stick', 0.99, 100],
[47865,'Lightsaber', 105.00, 1],
[1, 'Sonic Screwdriver', 99.99, 1]
]
Add more products to this list
Question: what does this code do?
print('*'*30)
s = 'abc'
l = len(s) # length
w = 20 # width
print(f'{" "*(w-l)}{s:>}')
Links
5 Useful F-String Tricks In Python
(YouTube)