You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)
The text was updated successfully, but these errors were encountered:
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 thesecond_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)
The text was updated successfully, but these errors were encountered: