#Chapter 7 - Exercise 2 – Theater Seating Revenue with Input Validation secA = 20 secB = 15 secC = 10 def getTickets(): A = int(input("tickets sold in section A: ")) B = int(input("tickets sold in section B: ")) C = int(input("tickets sold in section C: ")) return (A, B, C) def ticketsValid(A, B, C): while A > 300 or A < 0: print("ERROR: Section A has a limit of 300 seats") A = int(input("tickets sold in section A: ")) while B > 500 or B < 0: print("ERROR: Section B has a limit of 500 seats") B = int(input("tickets sold in section B: ")) while C > 200 or C < 0: print("ERROR: Section C has a limit of 200 seats") C = int(input("tickets sold in section C: ")) return (A, B, C) def calcIncome(A, B, C): incomeGenerated = A * secA + B * secB + C * secC print("The income generated is $%d" % (incomeGenerated)) def main(): A, B, C = getTickets() A, B, C = ticketsValid(A, B, C) calcIncome(A, B, C) main()
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question