You are on page 1of 4

5/27/2020 lab1 - Jupyter Notebook

In [21]:

print("*************************************************************************\n")
print("\nWELCOME TO STEADLTER STATIONERIES\n\n")
print("*************************************************************************\n")
print("\nPLEASE ENTER THE DETAILS BELOW")
n=1
while n==1:## Name Validation

name=input("\nNAME : ")
if name.strip().isalpha():
break;
else:
print ("Invalid Name, Please Enter Again")
n=1
while n==1:## Phone Number Validation

phone=input("\nCONTACT NUMBER : ")


if phone.strip().isdigit() and len(phone)==10:
break;
else:
print ("Invalid Phone Number, Please Enter Again")
n=1
l1=list() #list to store item name
l2=list() #list to store quantity
l3=list() #list to store amount after discount
list1=['pencils','crayons','paints','pen','books']# List 1 for Products
list2=[100,250,500,140,300]#List 2 for Price
p=1
totamt=0
while(p>0): #Conditional while loop for multiple selection
tot=0.0
print(" \nPlease choose from category : \n")
print(" 1. Pencils : 100 rs ")
print(" 2. Crayons : 250 rs ")
print(" 3. Paints : 500 rs")
print(" 4. Pen : 140 rs")
print(" 5. Books : 300 rs")
print(" 6. To Exit and Print Final Bill ")
p=input(" \nPlease Enter Your Choice : ")
p=int(p)

if p==6:
break; #to break out of loop and print final bill
else :

q=input(" \nPlease Enter The Quantity : ")


q=int(q)
#if else conditional operator for Selection
if (p == 1):
l1.append(list1[0])
l2.append(q)
print("\nThe product chosen is ",list1[0])
print("Cost is ",list2[0])
tot=q*list2[0] #amount after calculating with quantity

elif p == 2:
l1.append(list1[1])
l2.append(q)
print("\nThe product chosen is ",list1[1])
print("Cost is ",list2[1])
localhost:8888/notebooks/Documents/python/lab1.ipynb 2/6
5/27/2020 lab1 - Jupyter Notebook

tot=q*list2[1]

elif p == 3:
l1.append(list1[2])
l2.append(q)
print("\nThe product chosen is ",list1[2])
print("Cost is ",list2[2])
tot=q*list2[2]

elif p == 4:
l1.append(list1[3])
l2.append(q)
print("\nThe product chosen is ",list1[3])
print("Cost is ",list2[3])
tot=q*list2[2]

elif p == 5:
l1.append(list1[4])
l2.append(q)
print("\nThe product chosen is ",list1[4])
print("Cost is ",list2[4])
tot=q*list2[2]
#if else conditional check for discounts
if(tot>=100 and tot<500):
print("\n5% discount provided ")
d=(5/100)*tot
tot=tot-d
l3.append(tot)
elif(tot>=500 and tot<1000):
print("\n15% discount provided ")
d=(15/100)*tot
tot=tot-d
l3.append(tot)
elif(tot>=1000):
print("\n25% Discount Provided ")
d=(25/100)*tot
tot=tot-d
l3.append(tot)
else: l3.append(tot)
print("Your Amount is : ",tot)
totamt=totamt+tot #Amount after discount
print("=============================================================================")
print(" FINAL BILL ")
print("=============================================================================\n\n")
print("NAME OF CUSTOMER : ",name)
print("\nCONTACT NUMBER : ",phone)
print("\n\n")
print("\nItems\t\t\tQuantity\t\tAmount(after discount)")
length=len(l1)
for i in range(length): #for loop to Print the final bill
print("\n{}\t\t\t{}\t\t\t{}".format(str(l1[i]),str(l2[i]),str(l3[i]))) #format function

print("\nFINAL AMOUNT TO BE PAID IS : ",totamt) #final amount after purchase of all product
print("============================================================================")

*************************************************************************

WELCOME TO STEADLTER STATIONERIES

localhost:8888/notebooks/Documents/python/lab1.ipynb 3/6
5/27/2020 lab1 - Jupyter Notebook

*************************************************************************

PLEASE ENTER THE DETAILS BELOW

NAME : sar23
Invalid Name, Please Enter Again

NAME : Sarah

CONTACT NUMBER : 123h678008


Invalid Phone Number, Please Enter Again

CONTACT NUMBER : 9856432133

Please choose from category :

1. Pencils : 100 rs
2. Crayons : 250 rs
3. Paints : 500 rs
4. Pen : 140 rs
5. Books : 300 rs
6. To Exit and Print Final Bill

Please Enter Your Choice : 2

Please Enter The Quantity : 3

The product chosen is crayons


Cost is 250

15% discount provided


Your Amount is : 637.5

Please choose from category :

1. Pencils : 100 rs
2. Crayons : 250 rs
3. Paints : 500 rs
4. Pen : 140 rs
5. Books : 300 rs
6. To Exit and Print Final Bill

Please Enter Your Choice : 1

Please Enter The Quantity : 1

The product chosen is pencils


Cost is 100

5% discount provided
Your Amount is : 95.0

Please choose from category :

1. Pencils : 100 rs
2. Crayons : 250 rs
3. Paints : 500 rs
4. Pen : 140 rs
5. Books : 300 rs
localhost:8888/notebooks/Documents/python/lab1.ipynb 4/6
5/27/2020 lab1 - Jupyter Notebook

6. To Exit and Print Final Bill

Please Enter Your Choice : 5

Please Enter The Quantity : 3

The product chosen is books


Cost is 300

25% Discount Provided


Your Amount is : 1125.0

Please choose from category :

1. Pencils : 100 rs
2. Crayons : 250 rs
3. Paints : 500 rs
4. Pen : 140 rs
5. Books : 300 rs
6. To Exit and Print Final Bill

Please Enter Your Choice : 6


============================================================================
=
FINAL BILL
============================================================================
=

NAME OF CUSTOMER : Sarah

CONTACT NUMBER : 9856432133

Items Quantity Amount(after discount)

crayons 3 637.5

pencils 1 95.0

books 3 1125.0

FINAL AMOUNT TO BE PAID IS : 1857.5


============================================================================

In [ ]:

In [ ]:

localhost:8888/notebooks/Documents/python/lab1.ipynb 5/6

You might also like