+ 2

Help 🤷🏽‍♂️I don’t know whats wrong with this code

>>>> Def f(x): return (2*x)**2+(2*x)+3 >>>> num =[f(2)] if 1 ==1 print(“ f(x)=(2*x)**2+(2*x)+3\n = “) Num[0]

25th Feb 2018, 1:22 AM
Sulaiman Bada
Sulaiman Bada - avatar
6 Answers
+ 3
This works (missing : on if, uppercase, and num wasn't in print.): def f(x): return (2*x)**2+(2*x)+3 num =[f(2)] if 1 ==1: print(" f(x)=(2*x)**2+(2*x)+3\n = "+str(num[0]))
25th Feb 2018, 1:43 AM
John Wells
John Wells - avatar
+ 3
You're using Python shell?
25th Feb 2018, 1:34 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 2
Yea I’m using python shell
25th Feb 2018, 1:54 AM
Sulaiman Bada
Sulaiman Bada - avatar
+ 2
it converts the number into a string so it can be concatenated together with your equation string.
25th Feb 2018, 2:02 AM
John Wells
John Wells - avatar
+ 1
If it’s python, I know for a fact def should not be capitalized but that might just be a typo here. 🤔
25th Feb 2018, 1:35 AM
Jax
Jax - avatar
+ 1
What does +str mean?
25th Feb 2018, 1:55 AM
Sulaiman Bada
Sulaiman Bada - avatar