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.