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

  • Home
  • SEARCH
  • 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 8499495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:41:01+00:00 2026-06-11T00:41:01+00:00

Python is exhibiting a strange behaviour that I didnt witness before, not sure what

  • 0

Python is exhibiting a strange behaviour that I didnt witness before, not sure what I did or what happened but basically it doesnt operate in shell with decimals
if i type simple

>>> 2/3
0
>>> 3/2
1

if i try to format that through % or format() it doesnt do much either, basically it just doesnt recognize any decimal

>>> a =2/3
>>> a
0
>>> format(a, '.5f')
'0.00000'

I needed a simple division for my code to check something and all of a sudden I encountered something as bizzare as this

I use Python 2.7

  • 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-11T00:41:02+00:00Added an answer on June 11, 2026 at 12:41 am

    In Python 2, / performs “integer division” by default. If you put

    from __future__ import division
    

    at the top of your script, it will do the division you want, which will be the default behavior in Python 3. Alternatively, if you want to stay compatible with old Python versions (not recommended for new code), do

    2. / 3.
    

    or, with variables

    x / float(y)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Python is so dynamic that it's not always clear what's going on in a
Python regular expression I have a string that contains keywords but sometimes the keywords
Python is on version 2.7.3, but when i try to upgrade python through pip
Python beginner here. I have a text file that is sorted into columns: fields
Python does not print traceback messages from exceptions raised in daemon threads. For example,
Python documentation says that os.rename(src, dst) ... On Windows, if dst already exists, OSError
python newbie here. I'm writing the code to control an experiment that has multiple
Python has the idea of metaclasses that, if I understand correctly, allow you to
Python decorators are fun to use, but I appear to have hit a wall
Python loves raising exceptions, which is usually great. But I'm facing some strings I

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.