# myprogram.py # This is the MAIN or startup program class # imports from mydata import products from mymodules import myfooter, myheader # functions def fullname(fname, lname, age=None): # helper functions page 42 # positional args page 38 firstname = fname # var scope page 43 lastname = lname # var scope page 43 #ageInTenYears = int(age) + 10 #print(ageInTenYears) fullname = firstname + " " + lastname # + " Age: " + age print(fullname) def userInputs(): # keyword args page 38 firstName = input("Enter contact first name: ") lastName = input("Enter contact last name: ") age = input("Enter contact age: ") # string return firstName, lastName, age # returning the 3 props in memory to the program def myproducts(products): # iterative function page 39 # collection object (list,set,tuple,dict) is passed to the function for product in products: print("Product Name: " + product) # recursive function page 40 > a function that calls itself, instead of returning to the program class def sell_product(inventory): # inventory data type int if inventory > 0: # Base inventory print("Quantity available to sell: " + str(inventory)) # Ask the user if they want to enter another order # if exit() keywords anotherOrder = input("Do you want to enter another order? (yes/no): ") if anotherOrder == "no": exit() # Ask the order id and qty sold from the user orderID = input("What is the order id: ") # string # Qty qtySold = int( input(f"Enter quantity for {orderID}: ") ) # int qtySold print("Order ID: " + orderID) # currentInventory formula inventory - qtySold # use currentInventory below in place of the formula print(f"Quantity sold: {qtySold} , remaining inventory: {inventory - qtySold}") # inventory -= 1 return a new value to the class sell_product(inventory - qtySold) else: print("Out of inventory") #### Program Class #### def main(): myheader() # Container for myprogram print("My Program Stuff") firstName, lastName, age = userInputs() # call fullname(firstName, lastName, age) print("=== Product List ===") print("====================") myproducts(products) print("=== End of Product List ===") print("==== Inventory Counter ====") initial_inventory = 8 sell_product(initial_inventory) print("==== End of Inventory Counter ====") # Footer myfooter() # page 35 main statement if __name__ == "__main__": main()