this post was submitted on 14 Apr 2021
1 points (100.0% liked)

Python

3275 readers
1 users here now

News and discussions about the programming language Python


founded 5 years ago
MODERATORS
 

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?

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 0 points 3 years ago* (last edited 3 years ago) (1 children)

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.

[–] [email protected] 0 points 3 years ago (1 children)

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.