FAQ: Introduction to Functions - Multiple Parameters

This community-built FAQ covers the “Multiple Parameters” exercise from the lesson “Introduction to Functions”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Visualize Data with Python
Data Scientist
Analyze Data with Python
Computer Science
Analyze Financial Data with Python
Build Chatbots with Python
Build Python Web Apps with Flask
Data Analyst

Learn Python 3
CS101 Livestream Series

FAQs on the exercise Multiple Parameters

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!
You can also find further discussion and get answers to your questions over in #get-help.

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head to #get-help and #community:tips-and-resources. If you are wanting feedback or inspiration for a project, check out #project.

Looking for motivation to keep learning? Join our wider discussions in #community

Learn more about how to use this guide.

Found a bug? Report it online, or post in #community:Codecademy-Bug-Reporting

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

In case anyone else gets confused here. In the lesson it teaches to define a function we type
def function_name(parameter1, parameter2, parameter 3)
when running this you will run into a syntax error. simply retype to match this
def function_name(parameter1, parameter2, parameter 3):
not having the colon will cause a syntax error to appear


I’m wondering why the solution requires a space between hotel_rates and the comma. Anyone else come into this issue?


Please help. What’s amiss in the code below:

def calculate_expenses(plane_ticket_price , car_rental_rate , hotel_rate , trip_time):
car_rental_total = car_rental_rate * trip_time
hotel_total = hotel_rate * trip_time-10
print(car_rental_total + hotel_total + plane_ticket_price)
calculate_expenses(200, 100, 100, 5)

1 Like

Did you forget to indent when defining the function?


Can anyone explain to me few moments please?

1.Why we should do here the multiply action?
car_rental_total = car_rental_rate * trip_time

2. Why the output will be different if write the code not this way

hotel_total = hotel_rate * trip_time - 10

but this:

hotel_total = hotel_rate * trip_time
hotel_total =- 10

Thanks in the advance!

I’ll try and answer if I’m understanding your questions correctly:

1: You multiply because the car_rental_total variable is to represent the total cost of renting the car. Industry standard for car rental businesses is to charge clients on a hourly rate. In order to get a cost of a rental, it would require you to multiply the rate (price for renting) by the amount of time the car was used.

2: ‘=’ assigns a meaning to a variable. In your alternative way, by writing hotel_total = -10 you are making the variable literally -10, you arent reducing the total by 10.

By by using hotel_total = a second time, you are rewriting its meaning.

By doing it all in one line:

hotel_total = hotel_rate * trip_time - 10

It will now calculate ‘hotel_rate * trip_time - 10’ together to accurately make the hotel_total variable represent the total cost of the hotel stay.

I hope this explanation helps.

1 Like

I got it.
Thank you a lot for your explanation!

1 Like

I as a practice always use parenthesis when doing multiple calculations. I really think it should be

(hotel_rate * trip_time) - 10

Or at least it should be considered a valid answer. I know there is an order of how the +, _ * / work, but I don’t think I’ll remember them. I just know that hotel_rate * (trip_time - 10) would be very different than the answer you are wanting to get.

The other thing I don’t really understand is that I did
print(str(car_rental_total + hotel_total + plane_ticket_price))
and it wasn’t considered valid? I suppose I only have to use str when mixing different data types?


def calculate_expenses(plane_ticket_price, car_rental_rate, hotel_rate, trip_time):
  car_rental_total = car_rental_rate * trip_time
  hotel_total = hotel_rate * trip_time - 10
  print(car_rental_total + hotel_total + plane_ticket_price)
calculate_expenses(200, 100, 100, 5)

Hi, everything in this code is fine, but I just wanna ask why we do not need to add str( ) for the parameters in the print statement. Is it because we only use str( ) for printing variables that have numbers assigned to them, and we dont need to use str( ) for parameters?

There’s a couple of things on the go here so I’ll try and break it down. You may have seen simple print statements like print(3) before. Part of the machinery of print will try and get a string representation of this integer object so that print(str(3)) would have the same output as print(3).

So no, you don’t have to convert everything to a string before using print because it will do some of the formatting for you.

The other part of this is that expression using + operators is evaluated before being passed to print. So your call acts much the same as the following would-

temp = car_rental_total + hotel_total + plane_ticket_price

We know this is fine because we’re adding together three integers so we just get the sum of those integers as a new integer (and print does the formatting of that new integer for us).

You may have seen similar things that looked more like print('some string' + str(number)). If you consider what happens before the argument is ever passed to print then this makes sense.

# both of these will fail for slightly different reasons
text = '3' + 3
number = 3 + '3'

We cannot concatenate a string with an integer like this, or vice versa (we’d get a type error). So we may convert the integer to a string str(3) and then join it to the other string in which case we pass a single string to print and everything makes sense again.

temp = '3' + str(3)
Out: 33  # this is a string after all, it's just two characters

Hi guys,

I don’t get it. This is my code:

Write your code below:

def calculate_expenses(plane_ticket_price, car_rental_rate, hotel_rate, trip_time)
car_rental_total = car_rental_rate * trip_time
hotel_total = hotel_rate * trip_time - 10
print(car_rental_total + hotel_total + plane_ticket_price)

calculate_expenses(200, 100, 100, 5)

In Question 5 it says that the result is 1190. But I get a syntax error…WHY? What is wrong?

Thanks in advance. FElix