Needing help with Learn Python: Functions

Hello all. I’m completely stuck with this one code and I do not know how to figure it out without using the “Solutions” button, which I do not want to do. Here is my current code:



The function mult_two_add_three() prints a number multiplied by 2 and added to 3 . As it is written right now, the number that it operates on is always 5 .

Call the function and see what it prints to the console.

Stuck? Get a hint


Now, modify the function definition so that it has a parameter called number . Then delete the number = 5 assignment on the first line of the function.

Pass the number 1 into your function call.

The function prints the value of: 5*2+3
You have to use the function:

mult_two_add_three() #prints  13

Then you have to modify the function so that in the function definion: def mult_two_add_three():
You have to add number between the parentheses just simply.
Then you have to modify the function body so that you delete number = 5 because number will be the parameter and you don’t have to set it as a variable
Then just put 1 between the parentheses when you call the function.

Hope this helps :grinning:

I’m still lost, sorry. I have a learning disability where I get confused easily.

Your code should look like this:

def mult_two_add_three(number):
  print(number*2 + 3)
# Call mult_two_add_three() here:

Step 1. We are going to add a parameter called “Number” to the function. We do this by simply writing “Number” when defining the function.

Step 2. When we call the function, we need to define the parameter, so we are going to put “1” in the parentheses.

Step 3. Now it should run. You’ve learned how to define a function’s parameter while calling a function.

Ok, thanks for this answer.

What is the reason for the exercise?

def mult_two_add_three(): vs def mult_two_add_three(number):

and then when calling mult_two_add_three() vs mult_two_add_three(1)?

I believe it does provide the same output?

Sorry for the question I’m interested in the reasons for doing it?

1 Like

Hey @kieranhowell64812513! I believe the main reason behind this exercise is for you to understand that when you pass a parameter such as number, to a function, you do not need to go back to the function and change the value yourself, manually.

For example:

def mult_two_add_three():
    print(5 * 2 + 3)


In this case, everytime you want to change 5 to any other number, you have to go back into the function and do it yourself, manually, as i said before.

When in this example…

def mult_two_add_three(number):
    print(number * 2 + 3)

x = 5

You can simply put any number or variable as the argument when you call the function (the argument goes where x is placed, and it is the value that that the parameter, or in this case, number, receives).

Let’s say instead of 5, x = 6. This time, when you call the function and put x inside the parenthesis, you will be setting the value of number to 6 (x), and the output would be 15 -> (number (6) * 2 + 3).

Hope you got it, and if got any more questions you know the drill!

Thank you for everyone’s help!


train_force = get_force
copies the function get_force and stores it in train_force, it doesn’t get the result of the function being called
so when you print it, you get the memory address of the function
(Technically, it only makes a new reference to the function, not an independent copy of the function.)

train_force = get_force(train_mass, train_acceleration)
gets the result of calling get_force on train_mass and train_acceleration, and stores that in train_force.

1 Like