Skip to content

Instantly share code, notes, and snippets.

@kessl
Created September 19, 2022 15:37
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save kessl/4ff6e72ee1f2c6dbcfafc2495a7eb60c to your computer and use it in GitHub Desktop.
# simplest: round up using math.ceil
math.ceil(11 / 3)
# using integer division
result = 11 // 3
if result * 3 != 11: # or 11 % 3 != 0 or 11 % 3 > 0
result += 1
# smartass way 🙃 equivalent to the above
11 // 3 + (11 % 3 > 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment