Jul-25-2023, 09:56 AM
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.
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.