How Do I Print Values Of A Function For Multiple Inputs In Python?
Pyhton Code Here Completely new to programming so excuse my ignorance. Pretty clear what I was trying to do in the image attached I think. Had to give up and just rewrite the funct
Solution 1:
In Python 3, print is a function, so requires parentheses.
Use print(g(x))
instead of print g(x)
.
Solution 2:
Seems like it's working. The only change I did to your code is to rename the variable in the for loop and add the extra parens that was already mentioned.
def g(x):
return (x**7+3*x)/4
g(5)
Out[28]: 19535.0
for num in range(4,14):
print(g(num))
4099.0
19535.0
69988.5
205891.0
524294.0
1195749.0
2500007.5
4871801.0
8957961.0
15687139.0
Post a Comment for "How Do I Print Values Of A Function For Multiple Inputs In Python?"