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

1 Like

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?