To answer your first question: to call all of the functions you need to put the names of your functions into the main() function. But, you had several other errors so I have decided to walk you through the program, step-by-step.
First, we set the prices:
secA = 20
secB = 15
secC = 10
Here is the first function, getTickets()
def getTickets():
global A
A = int(input("Please enter the number of tickets sold in section A: "))
global B
B =int(input("Please enter the number of tickets sold in section B: "))
global C
C =int(input("Please enter the number of tickets sold in section C: "))
Notice the word global before I use the variable. This tells the computer that this variable can be used everywhere. Next, notice the double parentheses - since both int() and input() are functions, so we need to show that by doing that.
I fixed your code for the ticketsValid() function. Usually, it isn't a good idea to nest functions, so this is at the same indentation level as the above code.
def ticketsValid(A,B,C):
while A > 300 or A < 0:
print("ERROR: Section A has a limit of 300 seats\n")
A = int(input("Please enter the number of tickets sold in section A: "))
while B > 500 or B < 0:
print("ERROR: Section B has a limit of 500 seats")
B =int(input("Please enter the number of tickets sold in section B: "))
while C > 200 or C < 0:
print("ERROR: Section C has a limit of 200 seats")
C =int(input("Please enter the number of tickets sold in section C: "))
This gets the variables from above, and checks to see if they are valid. Notice that I added a check for negative numbers - you can't sell negative tickets.
Then we come to calcIncome(A,B,C):
def calcIncome(A, B, C):
total = A * secA + B * secB + C * secC
print ("The income generated is $%d" % (total))
First, we multiply the sections by the set prices to calculate the total. Then, we print it.
Lastly, we need to call the functions. I used your idea for a main() function, which uses the other functions. It looks like this.
def main():
getTickets()
ticketsValid(A,B,C)
calcIncome(A, B, C)
It simply calls the other functions, in the correct order, when run.
Lastly, we call the main() function by typing:
main()
I hope that this answered your question. If not, feel free to comment. If so, please check the green check mark next to my answer.