Python Forum
Get multiple values from function and total it.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get multiple values from function and total it.
#1
I have created a python program that is an ordering system in a resturant. The resturant has scheme of if any customer buys 4 pizzas, gets 1 drink for free and if any customer buys 4 pastas, they get 1 free bruchetta. I created the program and it can calculate the total for each order and display it but where I am stuck is, now at the end of the program, I need to display how may orders were taken, how much is the total sales and how many free drink and bruchetta were given.

#Pasta Prices

pasta1=9.5
pasta2=17.00
pasta3=27.50

#Pizza Prices

pizza1=10.99
pizza2=20.99
pizza3=29.99


    
def P():
    pizza=int(input("enter the number of pizzas for this order"))
    if pizza==1:
        pizza_sales=pizza1
    elif pizza==2:
        pizza_sales=pizza2
    elif pizza==3:
        pizza_sales=pizza3
    elif pizza>3:
        quotient=pizza//3
        remainder=pizza%3
        if remainder==1:
            pizza_sales=((quotient*pizza3)+pizza1)
        else:
            pizza_sales=((quotient*pizza3)+pizza2)
    this_order=pizza
    return pizza_sales,this_order,remainder,quotient


        
def PP():

    pasta=int(input("enther the number of pastas for this order"))
    
    if pasta==1:
        pasta_sales=pasta1
    elif pasta==2:
        pasta_sales=pasta2
    elif pasta==3:
        pasta_sales=pasta3
    elif pasta>3:
        quotient1=pasta//3
        remainder1=pasta%3
        if remainder1==1:
            pasta_sales=((quotient1*pasta3)+pasta1)
        else:
            pasta_sales=((quotient1*pasta3)+pasta2)
        this_order1=pasta
    return pasta_sales,this_order1,quotient1,remainder1
        

    


def B():
        pizza_sales,this_order,remainder,quotient=P()
        print("the total for",this_order,"pizzas is",pizza_sales)
        pasta_sales,this_order1,quotient1,remainder1=PP()
        print("the total for",this_order1,"pastas is",pasta_sales)
        print("So the total is",(pizza_sales+pasta_sales))
           


order='m'

while order=='m' or order=='M':    
    print("Please enter the order")
    \
    \
    a=input("Please enter P to order Pizza, T to order pasta or B to order both")
    if a== 'P'or a=='p':
         print("Current promotion: FREE drink for every 4 pizzas bought")
         pizza_sales,this_order,remainder,quotient=P()
         print ("your total for",this_order,"pizza(s) is",pizza_sales)
         print ("Free drinks given:", quotient-1)
         choice=input("Do you want to view the order summary for your last order?")
         if choice=='Y' or choice=='y':
            print ("Number of pizzas bought=",this_order)
            print ("Grand total for the order=",pizza_sales)
            print ("Free drinks given:", quotient)

    elif a=='T'or a== 't':
            pasta_sales,this_order1,quotient1,remainder1=PP()
            print ("pasta sales for this order",pasta_sales,"and the number of pastas is",this_order1)
            print ("Customer gets", quotient1-1 ,"free bruchetta")
            choice=input("Do you want to view the order summary for your last order?")
            if choice=='Y' or choice=='y':
                print ("Number of pastas bought=",this_order1)
                print ("Grand total for the order=",pasta_sales)
                print ("Customer gets", quotient1-1 ,"free bruchetta")
           
     
    
    elif a=='B' or a=='b':
        B()
            
            
        
    else:
        print("invalid order code")
        

    order=input("Press M to take more order and press any other key to end your shift")
I really appreciate everyone's time and effort and your help. If my question is unclear, please let me know so that I can paste the full case scenario to give a full perspective. Thank you
Reply


Messages In This Thread
Get multiple values from function and total it. - by nirlep - Feb-03-2019, 12:48 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  __init__() got multiple values for argument 'schema' dawid294 4 2,273 Jan-03-2024, 09:42 AM
Last Post: buran
  Adding values with reduce() function from the list of tuples kinimod 10 2,636 Jan-24-2023, 08:22 AM
Last Post: perfringo
  How to combine multiple column values into 1? cubangt 15 2,813 Aug-11-2022, 08:25 PM
Last Post: cubangt
  function accepts infinite parameters and returns a graph with those values edencthompson 0 855 Jun-10-2022, 03:42 PM
Last Post: edencthompson
Sad Iterate randint() multiple times when calling a function Jake123 2 2,040 Feb-15-2022, 10:56 PM
Last Post: deanhystad
  Function - Return multiple values tester_V 10 4,438 Jun-02-2021, 05:34 AM
Last Post: tester_V
  Xlsxwriter: Create Multiple Sheets Based on Dataframe's Sorted Values KMV 2 3,483 Mar-09-2021, 12:24 PM
Last Post: KMV
  Looking for help in Parse multiple XMLs and update key node values and generate Out.. rajesh3383 0 1,872 Sep-15-2020, 01:42 PM
Last Post: rajesh3383
  function not giving back total SephMon 1 1,678 Aug-25-2020, 12:46 PM
Last Post: deanhystad
  print function help percentage and slash (multiple variables) leodavinci1990 3 2,474 Aug-10-2020, 02:51 AM
Last Post: bowlofred

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020