I’ve started to learn programming Python (also i’m a beginner) and my code’s print result was “0”. Could someone explain why?

I mean, on my calculator hardware it results on something like “0.5555552”, this has anything to do with the Python Interpreter’s code?

  • roastpotatothief@lemmy.ml
    link
    fedilink
    arrow-up
    3
    ·
    edit-2
    3 years ago

    The first thing you need to know about programming: stackoverflow.com. Any question you will ever have, somebody has already posted the answer there.

    Once you are using python 3, you’ll find there are two types of division

    • integer division: 15//4=3
    • floating point (normal) division: 15/4=3.75

    Often you do want integer division, so use the // operator.

    • kazutrash@lemmy.mlOP
      link
      fedilink
      arrow-up
      2
      ·
      3 years ago

      I really appreciate that explaining, thank you. I’ve already heard about StackOverflow but never searched through it very much, from now i’m going to take a look over it as probably will help me a lot.

      • Adda@lemmy.ml
        link
        fedilink
        arrow-up
        2
        ·
        edit-2
        3 years ago

        You don’t even need to search for SO (Stack Overflow) specifically. It very often happens to be the first result in your search feed, especially when trying to search for something programming- or tech-related. Thinking about it, I have never searched for something through SO’s own search engine actually.