Skip to content

My Shopping python program  #1521

Open
Open
@Kim-Venom

Description

@Kim-Venom

#a shopping program that sells add and check out to customers

import time
import os

shopping_cart = 0

total_price = 0

item_list = []

#shopping function

def shopping ():
global shopping_cart
global total_price

print ("Here are lists of items for sale: ")
print ("1. Apple - $3")
print ("2. Soap - $6")
print ("3. Soda - $4")
print ("4. Pie - $8")
print ("5. Cake - $14 ")
print ("6. Exit \n")

while shopping_cart < 20:
    ch = int(input("Enter the numerical value of the goods you like to purchase: "))

    if ch == 1:
        print ("You have added Apple to you cart")
        shopping_cart = shopping_cart + 1
        total_price = total_price + 3
        item_list.append(" - Apple -")
        print ("You have " + str(shopping_cart) + " item/s  on your shopping cart")
        time.sleep (3)
        os.system('clear')
        print ("Here are lists of items for sale: ")
        print ("1. Apple - $3")
        print ("2. Soap - $6")
        print ("3. Soda - $4")
        print ("4. Pie - $8")
        print ("5. Cake - $14 ")
        print ("6. Exit \n")
    elif ch == 2:
        print ("You have added Soap to you cart")
        shopping_cart = shopping_cart + 1
        total_price = total_price + 6
        item_list.append(" - Soap -")
        print ("You have " + str(shopping_cart) + " item/s  on your shopping cart")
        time.sleep (3)
        os.system('clear')
        print ("Here are lists of items for sale: ")
        print ("1. Apple - $3")
        print ("2. Soap - $6")
        print ("3. Soda - $4")
        print ("4. Pie - $8")
        print ("5. Cake - $14 ")
        print ("6. Exit \n")
  
    elif ch == 3:
        print ("You have added Soda to your cart")
        shopping_cart = shopping_cart + 1
        total_price = total_price + 4
        item_list.append(" - Soda -")
        print ("You have " + str(shopping_cart) + " item/s  on your shopping cart")
        time.sleep (3)
        os.system('clear')
        print ("Here are lists of items for sale: ")
        print ("1. Apple - $3")
        print ("2. Soap - $6")
        print ("3. Soda - $4")
        print ("4. Pie - $8")
        print ("5. Cake - $14 ")
        print ("6. Exit \n")
  
    elif ch == 4:
        print ("You have added Pie to you cart")
        shopping_cart = shopping_cart + 1
        total_price = total_price + 8
        item_list.append(" - Pie -")
        print ("You have " + str(shopping_cart) + " item/s  on your shopping cart")
        time.sleep (3)
        os.system('clear')
        print ("Here are lists of items for sale: ")
        print ("1. Apple - $3")
        print ("2. Soap - $6")
        print ("3. Soda - $4")
        print ("4. Pie - $8")
        print ("5. Cake - $14 ")
        print ("6. Exit \n")
        
    elif ch == 5:
        print ("You have added Cake to your cart")
        shopping_cart = shopping_cart + 1
        total_price = total_price + 14
        item_list.append(" - Cake -")
        print ("You have " + str(shopping_cart) + " item/s  on your shopping cart")
        time.sleep (3)
        os.system('clear')
        print ("Here are lists of items for sale: ")
        print ("1. Apple - $3")
        print ("2. Soap - $6")
        print ("3. Soda - $4")
        print ("4. Pie - $8")
        print ("5. Cake - $14 ")
        print ("6. Exit \n")
    elif ch == 6:
        print ("Thank you for Shopping with us...")
        print("Below is your item lists in your cart: \n")
        print (item_list)
        print ("\nBelow is the total amount for all goods: \n")
        print("$" + str(total_price))
        exit ()

    else:
        print ("Invalid input Try again: ")
        time.sleep (3)
        os.system('clear')
        shopping()
        

print ("Thank you for Shopping with us..., your cart is full")
print("Below is your item lists in your cart: \n")
print (item_list)
print ("\nBelow is the total amount for all goods: \n")
print("$" + str(total_price))
exit ()

shopping()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions