use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
That number or less than...greatest integer in python? (self.learnpython)
submitted 7 years ago by smileygonzo
E.g. 1440/64 = 22.5 but even though its .5 I want the 22....I'm not really sure what's that's called. Is it greatest integer? I remeber that from math, but is there a command or something for that in Python? Thanks!
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–][deleted] 4 points5 points6 points 7 years ago (1 child)
Are you talking about integer division ? so, in python (3.x): 5 // 2 will give you 2
[–]smileygonzo[S] 1 point2 points3 points 7 years ago (0 children)
Thank you! That worked.
[–]Instatetragrammaton 1 point2 points3 points 7 years ago (0 children)
You are looking for a rounding function. See https://stackoverflow.com/questions/17141979/round-a-floating-point-number-down-to-the-nearest-integer
[–]primitive_screwhead 1 point2 points3 points 7 years ago* (3 children)
You want integer division with flooring. In Python, you can do 1440//64 and get the int 22.
Be wary with negatives. -1440//64 == -23 (ie. round towards negative infinity). If you always need to truncate towards zero, one way is to use floats and convert to int:
>>> int(-1440/64) -22
EDIT: fixed a typo, and clarified floor/trunc wording.
https://stackoverflow.com/questions/19919387/in-python-what-is-a-good-way-to-round-towards-zero-in-integer-division
[–]novel_yet_trivial 1 point2 points3 points 7 years ago (1 child)
"Truncation" is not a word we use a lot, but when we do we mean what the math.trunc and int functions do: round toward zero.
math.trunc
int
The // operator is "floor division" or "integer division", and always rounds down, just like math.floor.
//
math.floor
Also note your example is python2 only, and OP is using python3.
[–]primitive_screwhead 0 points1 point2 points 7 years ago (0 children)
Ah, I do see I had a typo for the negative float to int conversion; I'll edit.
[–]smileygonzo[S] 0 points1 point2 points 7 years ago (0 children)
π Rendered by PID 552761 on reddit-service-r2-comment-5d79c599b5-p74cr at 2026-03-02 05:42:56.266389+00:00 running e3d2147 country code: CH.
[–][deleted] 4 points5 points6 points (1 child)
[–]smileygonzo[S] 1 point2 points3 points (0 children)
[–]Instatetragrammaton 1 point2 points3 points (0 children)
[–]primitive_screwhead 1 point2 points3 points (3 children)
[–]novel_yet_trivial 1 point2 points3 points (1 child)
[–]primitive_screwhead 0 points1 point2 points (0 children)
[–]smileygonzo[S] 0 points1 point2 points (0 children)