Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8270563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:36:19+00:00 2026-06-08T06:36:19+00:00

When I type small integers with a 0 in front into python, they give

  • 0

When I type small integers with a 0 in front into python, they give weird results. Why is this?

>>> 011
9
>>> 0100
64
>>> 027
23

I’m using Python 2.7.3. I have tested this in Python 3.0, and apparently this is now an error. So it is something version-specific.

They are apparently still integers:

>>> type(027)
<type 'int'>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T06:36:21+00:00Added an answer on June 8, 2026 at 6:36 am

    These are numbers represented in base 8 (octal numbers).
    Some examples:

    Python 2 (old format)

    Note: these forms only work on Python 2.x.

    011 is equal to 1⋅8¹ + 1⋅8⁰ = 9,

    0100 is equal to 1⋅8² + 0⋅8¹ + 0⋅8⁰ = 64,

    027 is equal to 2⋅8¹ + 7⋅8⁰ = 16 + 7 = 23.

    Python 3 (new format)

    In Python 3, one must use 0o instead of just 0 to indicate an octal constant, e.g. 0o11 or 0o27, etc. Python 2.x versions >= 2.6 supports both the new and the old format.

    0o11 is equal to 1⋅8¹ + 1⋅8⁰ = 9,

    0o100 is equal to 1⋅8² + 0⋅8¹ + 0⋅8⁰ = 64,

    0o27 is equal to 2⋅8¹ + 7⋅8⁰ = 16 + 7 = 23.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using python 3 for a small extra credit assignment to write an RSA
I'm currently trying to teach myself PHP by doing a small image-processing type project
I am having an issue trying to make a small text-fantasy type game involving
The type of this function is T -> (T -> U) -> U .
This is the problem I ran into long time ago. I thought I may
I have a small-scale WPF application using VB.net as the code behind and I
I have an algorithm where I create two bi-dimensional arrays like this: TYPE TPtrMatrixLine
How can I resolve this? >>> class unslice: ... def __getitem__(self, item): print type(item),
I know this type of question has been asked before, but I could not
I have written small C++ console application and this is source code : #include<stdio.h>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.