0

in python it is showing error. .

for the following code it displaying error.output not getting as 15.why? >>> 5*03

23rd Jun 2017, 5:48 PM
Krishna Teja
Krishna Teja - avatar
5 odpowiedzi
+ 1
Just to be more specific, numbers starting with 0 were interpreted as octal (base 8) constants in python2. This was changed in python3.
23rd Jun 2017, 8:14 PM
Bogdan Sass
Bogdan Sass - avatar
+ 5
You don't have to type the triple angular brackets... it just symbolize the prompt at the command line interpreter (CLI)... And if you want run this code as a file (or here in code playground, which virtualize a file, not a CLI), you need to explicit that you want display the result of an expression, by assigning it to a variable and/or send it as parameter of the print() function (in CLI, works also, but default behaviour is to log return value of expression evaluated. Finally, as said in previous answers, the 0 directly before the 3 is invalid syntax in Python 3 (and code playground run Python 3) ^^
23rd Jun 2017, 7:21 PM
visph
visph - avatar
+ 4
Simply put, python 3.5 does not support the syntax of having a 0 in front of an integer. It does however still work with floats. Just use: 5*3
23rd Jun 2017, 5:51 PM
Sapphire
+ 2
You're getting an invalid token error. If you want to represent a decimal use "." So 5 * 0.3 I'm not sure what you was trying to do but having the zero before the 3 is the problem.
23rd Jun 2017, 5:52 PM
Don
Don - avatar
- 1
Just do 5*3 and you'll get 15. A number starting with a 0 is only allowed in Python 2.
23rd Jun 2017, 5:52 PM
Frederik Bussler
Frederik Bussler - avatar