1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
garik1379 [7]
3 years ago
5

There are three seating categories at a stadium. Class A seats cost $20, Class B seats cost $15, and Class C seats cost $10. Wri

te a program that asks how many tickets for each class of seats were sold, then displays the amount of income generated from ticket sales.
Computers and Technology
1 answer:
Westkost [7]3 years ago
5 0

Answer:

Following are the program to this question:

def calculate_income(num,seat):#defining method calculate_income

   if seat=="A": #defining condition for seat a

       return num * 20 #return value

   if seat=="B": #defining condition for seat b

       return num * 15 #return value

   if seat=="C": #defining condition for seat c

       return num * 10 #return value

def show_income(a,b,c): #defining method show_Income

   sum=a+b+c # add total seats income

   print("Income for A class seats: $",a) #print value

   print("Income for B class seats: $",b) #print value

   print("Income for C class seats: $",c) #print value

   print("Total Income: $",sum) #print value

def main(): # defining main method

   a=int(input("Enter class A seats: ")) #input seats a value

   b=int(input("Enter class B seats: ")) #input seats b value

   c=int(input("Enter class C seats: ")) #input seats c value

   a_income=calculate_income(a,"A")  #call method for seat a

   b_income=calculate_income(b,"B") #call method for seat b

   c_income=calculate_income(c,"C") #call method for seat c

   show_income(a_income,b_income,c_income) # call method show_income for print all seat value

main()

Output:

Enter class A seats: 2

Enter class B seats: 3

Enter class C seats: 2

Income for A class seats: $ 40

Income for B class seats: $ 45

Income for C class seats: $ 20

Total Income: $ 105

Explanation:

The description of the above program can be described as follows:

  • In the above python program, three methods "calculate_income, show_income, and the main method" were defined.  
  • The method "calculate_income" accepts two-variable "num and seat" as the parameter, inside the method a three if block is used, that calculate all types of seat class rate and returns its value.
  • In the "show_income", we add all the seat value in the sum variable and use the print method, that prints all seat cost, and total cost.
  • In the main method, we input all seat value from user input and pass into the calculate_income method and collect all the return value, after calculating calculate_income we pass its return value into the show_income method, that prints all value.
You might be interested in
Write a generator function named count_seq that doesn't take any parameters and generates a sequence that starts like this: 2, 1
-BARSIC- [3]

Answer:

#required generator function

def count_seq():

   #starting with number 2. using string instead of integers for easy manipulation

   n='2'

   #looping indefinitely

   while True:

       #yielding the integer value of current n

       yield int(n)

       #initializing an empty string

       next_value=''

       #looping until n is an empty string

       while len(n)>0:

           #extracting first digit (as char)

           first=n[0]

           #consecutive count of this digit

           count=0

           #looping as long as n is non empty and first digit of n is same as first

           while len(n)>0 and n[0]==first:

               #incrementing count

               count+=1

               #removing first digit from n

               n=n[1:]

           #now appending count and first digit to next_value

           next_value+='{}{}'.format(count,first)

       #replacing n with next_value

       n=next_value

#testing, remove if you don't need this

if __name__ == '__main__':

   #creating a generator from count_seq()

   gen=count_seq()

   #looping for 10 times, printing next value

   for i in range(10):

       print(next(gen))

Explanation:

6 0
3 years ago
The internet has provided great opportunities for fundraising. true/false
alekssr [168]
True, sites such as kickstarter and just giving are fantastic examples of such.
8 0
3 years ago
Any device that uses light to read and write information.
netineya [11]

Answer:

Optical Storage Device

3 0
3 years ago
Among the second generation homebconsole companies which managed to come out on top
Vikentia [17]
The second generation of home consoles occurred from (1976-1988) at this time the most popular and consoled regarded as best was the Atari 2600
3 0
2 years ago
How to solve this?<br> In c++
andrey2020 [161]

Explanation:

6* 49 because you multiply the number of dots in the first figure by 49

8 0
3 years ago
Other questions:
  • Can someone please help me with this question?
    12·1 answer
  • Which of the following is true about occupations within the STEM fields? Many occupations use mathematics, even if it is not the
    11·2 answers
  • Write a c++ function, largestnum, that takes as parameters a double array and its size and returns the index of the last occurre
    14·1 answer
  • What is an audit trail?
    7·2 answers
  • Namecoin is an alternative blockchain technology that is used to implement decentralized version of Routing Banking System.A. Tr
    14·1 answer
  • Each of the outcomes listed below is a result of executing the following script except for one. Which one? CREATE ROLE ExampleRo
    6·1 answer
  • Which best describes how a supporting database will be structured?
    10·1 answer
  • What is the most vulnerable information that should be protected to prevent unauthorized access to your online files and records
    8·1 answer
  • Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
    12·1 answer
  • An e-commerce client is moving from on-premise, legacy systems to a cloud-based platform. During the transition, the client is a
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!