1

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 function. Why isn't it accepting g(x)?

def g(x):
    return (x**7+3*x)/4

and then

for x in range(4,14):
    print g(x)

didn't work so I used

for x in range(4,14):
    y=(x**7+3*x)/4
    print(y)

Thanks!

John Man
  • 13
  • 3

2 Answers2

0

In Python 3, print is a function, so requires parentheses.

Use print(g(x)) instead of print g(x).

Brenden Petersen
  • 1,993
  • 1
  • 9
  • 10
0

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
mnickey
  • 727
  • 1
  • 6
  • 15