Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

There are three seating categories at the college football stadium. For a footba

ID: 3816950 • Letter: T

Question

There are three seating categories at the college football stadium. For a football game, a season ticket costs $15, non-season tickets cost $12, and student seating cons $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 these values to a function by calling the following function: showIncome (SeasonSeats, NonSeasonSeats, StudentSeats) The function should be declared like this: def showIncome (x, y, z): Use the function call and the function definition exactly as given above. Output should be: Total Income: $ 0000.00

Explanation / Answer

Answer: Below is the code solution

#!/usr/bin/python
def showIncome(x,y,z):
   if(x >0 and y > 0 and z >0):
       totalInc = float(15*x) + float(12*y) + float(9*z)
       finalResult = "Total Income: $" + str(totalInc)
       return finalResult
   else:
       return "Not a valid integer. Please enter a valid value greater than 0."

seasonTkts = raw_input("Enter number of season tickets sold: "); #ask the user for number of season tkts
nonseasonTkts = raw_input("Enter number of non-season tickets sold: "); #input for non-season tkts
studentTkts = raw_input("Enter number of student seating tickets sold: "); #input for student seating tkts
seasonTkts = int(seasonTkts); #convert the season input string to integer
nonseasonTkts = int(nonseasonTkts); #convert the non-season input string to integer
studentTkts = int(studentTkts); #convert the student seating input string to integer
finalRes = showIncome(seasonTkts, nonseasonTkts, studentTkts); #call the function to calculate totalprice
print finalRes #print the calculated totalprice

To run the program :

Please run the command in the command line : python <filename of the python program>