r/CodingHelp • u/absolutestinker • Oct 08 '21
[Python] Not sure how to fix the syntax error
50
5
6
u/Arag0ld Oct 08 '21
You have to say 2*x instead of 2x. Programming languages don't know what 2x means
3
2
1
0
Oct 08 '21
[deleted]
2
u/skellious Intermediate Coder Oct 08 '21
They have, it's jupyter notebook. It works differently to normal python. Things persist between cells.
5
u/MythGuy Oct 08 '21
It's a joke. 2x is a how you might write something in math, but in the program it needs to have an operator because while OP may have imported the math module, they haven't imported math
1
2
9
u/WelcomeToFungietown Oct 08 '21
As others have pointed out, it should be 2*x. Sidenote: as you've already defined x=math.pi, it would make more sense for you to do print (f(x), ...) instead of having to write math.pi over and over. Just a good habit for you.