Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to make a bill in python

tprice = 0
tup = [['apple','100','2'],['blackberry','100','23']]
f= open(filename,'w')
g= open('recpt.txt','r')
lines = g.readlines()
for line in lines:
    base = line.split()
    tup.append(base)
print('S.no','	','Product','	','Unit','	','Price')
for i in range(len(tup)):
    if len(tup[i][0]) <= 7:
      print([i+1],'	',tup[i][0],'	','	',tup[i][2],'	',tup[i][1])
    else:
        print([i+1], '	', tup[i][0], '	', tup[i][2],'	',tup[i][1])
    price = int(tup[i][1])
    tprice += price
print(tprice)
Comment

how to make a bill in python

tprice = 0
tup = [['apple', '100', '2'], ['blackberry', '100', '23']]
myformat = "{:<10}{:<25}{:<5}{}"

f = open(filename, 'w')
g = open('recpt.txt', 'r')
lines = g.readlines()

for line in lines:
    base = line.split()
    tup.append(base)

print(myformat.format('S.no', 'Product', 'Unit', 'Price'))

for i in range(len(tup)):
    if len(tup[i][0]) <= 7:
        print(myformat.format(str([i + 1]), tup[i][0], tup[i][2], tup[i][1]))
    else:
        print(myformat.format(str([i + 1]), tup[i][0], tup[i][2], tup[i][1]))

    price = int(tup[i][1])
    tprice += price

print(tprice)
Comment

python bill

tprice = 0
tup = [['apple','100','2'],['blackberry','100','23']]
f= open(filename,'w')
g= open('recpt.txt','r')
lines = g.readlines()
for line in lines:
    base = line.split()
    tup.append(base)
print('S.no','	','Product','	','Unit','	','Price')
for i in range(len(tup)):
    if len(tup[i][0]) <= 7:
      print([i+1],'	',tup[i][0],'	','	',tup[i][2],'	',tup[i][1])
    else:
        print([i+1], '	', tup[i][0], '	', tup[i][2],'	',tup[i][1])
    price = int(tup[i][1])
    tprice += price
print(tprice)
Comment

python: total for the bill

def bill_total(bill, tax_rate):
    sub_total = 0
    taxable_total = 0
    for line_item in bill:
        line_total = line_item["quantity"] * line_item["item_cost"]
        sub_total += line_total
        if line_item["taxable"]:
            taxable_total += line_total

    return sub_total + (taxable_total * tax_rate)
Comment

PREVIOUS NEXT
Code Example
Python :: how to add labels on bar of barchart seaborn 
Python :: python multithreading 
Python :: append string python 
Python :: liste compréhension python 
Python :: get coordinates of netcdf in python 
Python :: python 3 tkinter treeview example 
Python :: python string continue next line 
Python :: re python3 
Python :: how to read .xlsx file in python 
Python :: marshmallow default value 
Python :: pandas.get_dummies 
Python :: sort dict of dicts by key 
Python :: docker opencv python libGL.so.1: cannot open shared object file: No such file or directory 
Python :: how to find the longest string python 
Python :: matplotlib 
Python :: how to use django-rest-framework-datatables 
Python :: django form example 
Python :: python factor number 
Python :: python loc 
Python :: pandas remove whitespace 
Python :: how to convert string to datetime 
Python :: flask where to put db.create_all 
Python :: remove item from list 
Python :: python get text of QLineEdit 
Python :: how to convert pandas price column to integer 
Python :: python sort comparator 
Python :: python pyaudio error 
Python :: print output 
Python :: mysql store numpy array 
Python :: create_polygon tkinter 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =