Kay,
first i am going to start this off by saying this is for my intro to prog. class (meaning im a beginner) so sorry if this is a stupid question or i'm missing something stupid.

HOWEVER I am supposed to make a program to report the income for football tickets sold.
it must end up looking like this:
How many season ticket seats were sold? 100
How many non-season ticket seats were sold? 300
How many student seats were sold? 200
Total Income: $6900.00

here is the actual assignment:
There are three seating categories at ACU Elmer Gray Stadium. For a football game, a season ticket costs $15, non-season ticket costs $12, and student seating costs $9. Write a program that asks how many tickets were sold for each category of seating, and then display the amount of income generated from ticket sales.
Pass those values to a function by calling the following function:

showIncome(SeasonSeats, NonSeasonSeats, StudentSeats)

The function should be declared like this:

def showIncome(incomeSeason, incomeNonSeason, incomeStudent):

Use the function call and the function definition exactly as given above.


Python keeps telling me "SeasonSeats is not defined". What am I doing wrong?

def showIncome(incomeSeason, incomeNonSeason, incomeStudent):
    income = float(incomeSeason) + float(incomeNonSeason) + float(incomeStudent)
    print("Total Income: $%.2f" %income)

showIncome(SeasonSeats, NonSeasonSeats, StudentSeats)
SeasonSeats = input("How many season ticket seats were sold?")
NonSeasonSeats = input("How many non-season ticket seats were sold?")
StudentSeats = input("How many student ticket seats were sold?")

SeasonSeats = SeasonSeats * 15.0
NonSeasonSeats = NonSeasonSeats * 12.0
StudentSeats = StudentSeats * 9.0

Recommended Answers

All 7 Replies

You are using variable at line 5 and taking input at line 6, do you see anything wrong?

no i dont.
I'm sure it is but i dont understand why. that is what i wrote down from class when my teacher went over it.

What kind of value it would have at line 5 and what value your function would print before asking the value from user?

what?
i would input a string and it would send a string.
But i feel like thats not what you're saying.

You are doing, simplified, printing a+b before asking value of a or b. Basically you would need time machine for it to succeed.

so are you saying i should:

SeasonSeats = input("How many season ticket seats were sold?")
NonSeasonSeats = input("How many non-season ticket seats were sold?")
StudentSeats = input("How many student ticket seats were sold?")
showIncome(SeasonSeats, NonSeasonSeats, StudentSeats)

thank you so much.
I totally understand now!!!
i feel so stupid. but thanks!!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.