#Theater seating revenue with input validation #Define cost of seating in each section costA = 20 costB = 15 costC = 10 ticketsales = 0 #Get number of tickets sold in each section print("This program calculates the amount of revenue generated by ticket sales") A = float(input("How many tickets were sold for section A seating?")) B = float(input("How many tickets were sold for section B seating?")) C = float(input("How many tickets were sold for section C seating?")) #Validate and display ticket sales or error message(s) if (A<0 or A>300): print("Invalid. There are 300 seats in section A.") elif (B<0 or B>500): print("Invalid. There are 500 seats in section B.") elif (C<0 or C>200): print("Invalid. There are 200 seats in section C.") else: ticketsales = (costA * A) + (costB * B) + (costC * C) print( "Ticket sales this evening amount to ${:,.2f}".format(ticketsales))
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