I’m new with python, I’m using python 2.7
when I typed this on python shell:
print 01
print 010
print 0100
print 01000
It gives this result
1
8
64
512
I tried to understand why it gave that but unfortunately I didn’t get the point.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If a number starts with
0, it is interpreted as octal, or base 8. Just do:And your problem will be solved.
More on octal: http://en.wikipedia.org/wiki/Octal
Here is a way to understand octal easier:
and so on. Octal just uses digits from 0 to 7.
Hope this helped!