![]() |
TypeError Decoration Intuition - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: TypeError Decoration Intuition (/thread-40421.html) |
TypeError Decoration Intuition - EddieG - Jul-25-2023 The instructor did not completed the code and i tried to run it, I am getting a name error why? Here is the code: def calcFormula1(x,y,z): return x*y+x/2 +2 def calcFormula2(x,y): return x*x*x +y*y*y +x+y+10 def printOutputReport1(func, x,y,z): z=func(x,y) print("----------This is a report for your formula------------") print("You X variable is:", x) print("You Y variable is:", y) print("The result of your formula is ", z) def printOutputReport2(func, x,y): z=func(x,y) print("----------This is a report for your formula------------") print("You X variable is:", x) print("You Y variable is:", y) print("The result of your formula is ", z) printOutputReport1(calcFormula1, 4 , 2) printOutputReport2(calcFormula2, 7 , 2) Here is the result coming out: TypeError Traceback (most recent call last) Cell In[20], line 23 19 print("You Y variable is:", y) 20 print("The result of your formula is ", z) ---> 23 printOutputReport1(calcFormula1, 4 , 2) 24 printOutputReport2(calcFormula2, 7 , 2) TypeError: printOutputReport1() missing 1 required positional argument: 'z' What is missing in the argument, Asigning value to (z) does not solve the code. Your input is most appreciated. RE: TypeError Decoration Intuition - deanhystad - Jul-25-2023 You are not getting a name error. You are getting a type error. You only pass 3 arguments to a function that expects 4. |