Python Forum
trouble with functions "def", calling/defining them
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
trouble with functions "def", calling/defining them
#1
Question 
please suggest the right forum or site if this is not the correct place, thank you!

Hello all, I am currently having trouble understanding an error I receive when running my code
error:
Traceback (most recent call last):
  File "main.py", line 32, in <module>
    showIncome()
TypeError: showIncome() missing 6 required positional arguments: 'num_aTickets', 'num_bTickets', 'num_cTickets', 'aRevenue', 'bRevenue', and 'cRevenue'
My code with comments/notes: the error happens in the end when calling showIncome()" I am having trouble within "def showIncome():" as well as calling/figuring out the a/b/cRevenue variables in the print statements. any help or resources explaining this will be greatly beneficial as my teacher and book do not seem to be helping much ( i have tried stackoverflow but reached my question limit this week and am resorting to this forum)
# Your main function should get the number of seats sold for each category. The values should be sent to a calcIncome function.
# The calcIncome function should calculate the income from each category. Those values should be returned to the main function and those values should be sent to the showIncome function.
# The showIncome function should calculate the total income generated from the ticket sales, display the income generated from each category AND display the total income generated.

def main():
    # obtain number of tickets/seats for each type from user
    num_aTickets = int(input('Enter number of class a tickets sold: '))
    num_bTickets = int(input('Enter number of class b tickets sold: '))
    num_cTickets = int(input('Enter number of class c tickets sold: '))
    return num_aTickets, num_bTickets, num_cTickets 


def calcIncome(aTickets, bTickets, cTickets):
      # revenue made from each and returns total revenue from sales
    aCost = 20
    bCost = 15
    cCost = 10
    aRevenue = aTickets * aCost
    bRevenue = bTickets * bCost
    cRevenue = cTickets * cCost
    return (aRevenue + bRevenue + cRevenue)


def showIncome(num_aTickets, num_bTickets, num_cTickets, aRevenue, bRevenue, cRevenue):
    income = calcIncome(num_aTickets, num_bTickets, num_cTickets)
    print('the revenue collected from total ticket sales is', income)
    print('the revenue collected from class a ticket sales is', aRevenue)
    print('the revenue collected from class b ticket sales is', bRevenue)
    print('the revenue collected from class c ticket sales is', cRevenue)


showIncome()
Reply


Messages In This Thread
trouble with functions "def", calling/defining them - by Duck_Boom - Oct-21-2020, 01:09 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Calling functions by making part of their name with variable crouzilles 4 1,789 Nov-02-2023, 12:25 PM
Last Post: noisefloor
  Calling functions from within a class: PYQT6 Anon_Brown 4 6,518 Dec-09-2021, 12:40 PM
Last Post: deanhystad
  Defining Functions theturtleking 4 3,770 Dec-07-2021, 06:45 PM
Last Post: deanhystad
  Defining multiple functions in the same def process sparkt 5 4,007 Aug-09-2020, 06:19 PM
Last Post: sparkt
  Calling C functions with PyObjects jibarra 6 3,791 Jul-17-2019, 02:52 PM
Last Post: jibarra
  Defining functions TommyAutomagically 1 2,369 Apr-25-2019, 06:33 PM
Last Post: Yoriz
  calling os functions not in module os Skaperen 2 3,387 Nov-10-2018, 01:54 AM
Last Post: Skaperen
  Trouble calling functions in main function RedSkeleton007 6 6,271 Nov-11-2017, 01:22 PM
Last Post: sparkz_alot
  Calling functions from another file jp2017 11 32,935 Oct-11-2017, 10:58 PM
Last Post: snippsat
  Having trouble defining variable tannishpage 6 6,784 Mar-23-2017, 01:04 PM
Last Post: Ofnuts

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020