 # Advanced Python Code Challenge "5. All Operations"

Hi everyone! I have decided to learn coding/programming over during this quarantine and have joined the Python 3 course here at Codeacademy. I am having trouble with the last challenge in the link below. Especially with the following parts:
"Third, print the first number printed, multiplied by the second number
Finally, return the third number printed mod a."
I am drawing a blank on how to approach the third step in particular. The first and second I am assuming is just adding and subtracting the parameters. I have had a stab with the following:

``````def lots_of_math(a, b, c, d):
print(a + b)
print(c - d)
``````

But when I get to the third step I am led to believe this is not the case. Should I be defining the first two print lines. I would appreciate any guidance towards the right direction. Thank you in advance.

It’s up to you exactly how you complete this task either define the results of these statements (a+b), (c-d) before the print statements and then sum them before using `return` or simply calculate the two values and combine them after the print statements then `return` that. I wouldn’t worry too much about optimising anything just yet, especially in Python.

1 Like

Hello @ajax9829619359, welcome to the forums!

What @tgrtim said is very good, and I will expand on it:

So:

This is asking you to multiply the first number that you printed `print(a + b)`, and multiply it be the second. One way to do this would be to store the first value printed in a variable:

``````a = "a number"#This is your number that you want to print
print(a)
``````

This way you can then access this number, using the variable `a` (or whichever one you choose).

This just mean find the modulus (remainder) of the third number you printed (the multiplication) by the parameter `a`.

This is how I would do it, using variables-of course you could do it in less lines, but that might affect the readability
``````def lots_of_math(a, b, c, d):
first_printed = (a + b)
print(first_printed)
second_printed = (c - d)
print(second_printed)
third_printed = (first_printed * second_printed)
print(third_printed)
return third_printed % a
``````

I hope this helps!

3 Likes