What is the syntax for basic math | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

What is the syntax for basic math

I cannot do basic math in my playground as it is said in the lesson. It says I have the wrong syntax

14th Oct 2019, 4:55 PM
Cole Williams
10 Answers
+ 6
If you type 3 + 4 and hit Run you will get a syntax error. If you type print(3 + 4) and hit Run you will get 7
14th Oct 2019, 5:02 PM
David Ashton
David Ashton - avatar
+ 3
Don't use ">>>" in the playground. ">>>" means an executable line on console. Console is a programming tool, which let you run statements by pressing enter.
14th Oct 2019, 5:49 PM
Seb TheS
Seb TheS - avatar
+ 2
It works thank you both
14th Oct 2019, 5:04 PM
Cole Williams
+ 1
This is in python
14th Oct 2019, 4:58 PM
Cole Williams
+ 1
Can you post your code?
14th Oct 2019, 4:59 PM
Odyel
Odyel - avatar
14th Oct 2019, 5:02 PM
Cole Williams
+ 1
Use the eval function. Example: print(eval(1+1)) 2 print(eval(5+6-4)) 7
14th Oct 2019, 5:36 PM
Jannik Müller
Jannik Müller - avatar
+ 1
In your code, if you change line 1 from >>> 2+2 to result = 2+2 it will work too 🙂
14th Oct 2019, 7:42 PM
David Ashton
David Ashton - avatar
0
You might want to make your own question board thing. There is also a lesson on it somewhere I will tell you when I find it
17th Oct 2019, 9:09 PM
Cole Williams
0
I found a couple lessons on interviewing and stuff you could look at
17th Oct 2019, 9:10 PM
Cole Williams