'How to ask if a user is a member and if so, display their discounted price and how to add all values up? [closed]

I want to ask the user if they are members and if so, give them a 5% discount on the seats they have purchased, if they are not members, there is no discount. I also want to display that discounted price. Also, how would I go about adding up all the final prices and displaying those as well? I don't know where to start with this, any help is appreciated, thanks. There may be some formatting issues, but here is my code:

def main():
 print("Your final price for Orchestra seats will be $",get_orchp())
 print("Your final price for Center seats will be $",get_centerp())
def get_orchp():
 ORCH_SEATS = 75
 frontseats = float(input('Enter the number of Orchestra seats you want to purchase : '))
 Finalorchp = ORCH_SEATS * frontseats
 member = str(input('Are you a member of the local theater group? Enter y or n: '))
 if member == 'y':
        discount = 0.5
        disc = Finalorchp * discount
        Findiscorchp = Finalorchp - disc
 elif member == 'n':
  print('There is no discount for non-members')
return Finalorchp
return findiscorchp
def get_centerp():
 CENTER_SEATS = 50
 middleseats = float(input('Enter the number of Center Stage seats you want to purchase : '))
 Finalcenterp = CENTER_SEATS * middleseats
 return Finalcenterp
main()


Solution 1:[1]

This code does what you want. you can see that in the code I have returned both price and discount amount from the getorchp() function as a tuple and using which I have printed the actual price and discount in the main function. If the user is not a member the discount will be zero and in the main function, I have added both orchestra seats and center seat price and printed the total final price. This code answers all questions you have asked

def main():
  orc = get_orchp()
  print("Your final price for Orchestra seats will be $",orc[0], " and discount is ", orc[1])
  cen = get_centerp()
  print("Your final price for Center seats will be $",cen)
  print("total final price", orc[0]+cen)
def get_orchp():
  ORCH_SEATS = 75
  frontseats = float(input('Enter the number of Orchestra seats you want to purchase : '))
  Finalorchp = ORCH_SEATS * frontseats
  member = str(input('Are you a member of the local theater group? Enter y or n: '))
  if member == 'y':
    discount = 0.5
    disc = Finalorchp * discount
    Findiscorchp = Finalorchp - disc
    return (Findiscorchp, disc)
  elif member == 'n':
    print('There is no discount for non-members')
    return (Finalorchp, 0)

def get_centerp():
  CENTER_SEATS = 50
  middleseats = float(input('Enter the number of Center Stage seats you want to purchase : '))
  Finalcenterp = CENTER_SEATS * middleseats
  return Finalcenterp
main()

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1