Why do I need to give print command for mathematical operations? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

Why do I need to give print command for mathematical operations?

In Simple operation chapter, it is said that python can calculate directly. "Python has the capability of carrying out calculations. Enter a calculation directly into the Python console, and it will output the answer." There was no result when I entered 2+2 in the code playground. However print(2+2) gives output 4. But print("2+2") gives 2+2.

23rd Mar 2017, 11:30 AM
Dex
Dex - avatar
2 Respostas
0
in a proper IDE (not the solo playground) entering 2+2 does result in 4 "2+2" is a string, so it will always be printed as 2+2 onto the screen. it isn't 2 numbers with an operator in the middle, it is basically words that look like 2+2
23rd Mar 2017, 2:01 PM
LordHill
LordHill - avatar
0
Thanks Justin
25th Mar 2017, 12:43 PM
Dex
Dex - avatar