Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print v Return video - Day 10 #17

Open
liamoc89 opened this issue Nov 30, 2020 · 0 comments
Open

Print v Return video - Day 10 #17

liamoc89 opened this issue Nov 30, 2020 · 0 comments

Comments

@liamoc89
Copy link

During this video, when calculating the second answer, you use the following code:

second_answer = calculation_function(calculation_function(num_1, num_2), num_3)

print(f"{first_answer} {operator} {num_3} = {second_answer}")

When you ran this code, your first calculation was 3 + 2 = 5, then you used 5 and chose the * operator to multiply by num_3, which you chose as 3.
The printed f-string displayed 5 * 3 = 18 in the console, which is obviously incorrect.

After running through the code on pythontutor.com, it appears as though when calculating the second answer, you're changing the operator so the calculation_function(num_1, num_2) part of the second_answer, actually multiplies the first 2 numbers together, before carrying out the same calculation with num_3.

i.e - 3*2 = 6, then using 6 as the value of calculation_function(num_1, num_2)

If you're using the same operator both times, there won't be an issue here, however, it seems better just to use
second_answer = calculation_function(first_answer, num_3)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant