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 :: pydrive set parents 
Python :: How did you determine the chromosome numbers and how does that relate to heredity? 
Python :: setheading in python 
Python :: flask extends two base.html 
Python :: how to write statements in python 
Python :: command run test keep db python 
Python :: adjusted price in crsp pandas 
Python :: rotate an image python keras 
Python :: how to convert csv columns to text python 
Python :: sklearn cheat sheet 
Python :: python messaging networking 
Python :: how to check local endianness with Python ? 
Python :: comment faire un long commentaire en python 
Python :: PN generator 
Python :: Reading from a file way03 
Python :: how to call a function in python? 
Python :: scapy get packet destination port python 
Python :: get external ip address python 
Python :: pandas mappin ID to value in different row 
Python :: nvidia-smi with user name 
Python :: plotly scroll zoom 
Python :: python regex compile 
Python :: np logical and 
Python :: Passive to active Python 
Python :: function transformer and feature union 
Python :: docker python no module named 
Python :: allow django imagefield accept base 64 image 
Python :: 1044 uri solution 
Python :: python loop through specific angle 
Python :: how to create a sub project in django 
ADD CONTENT
Topic
Content
Source link
Name
5+8 =