Calculation to calculate the number of pages based on the number of elements

If I have 177 elements and each page has 10 elements, then I will have 18 pages.

I am new to python and have used any of the math related functions.

How can I calculate 177/10 and then round to get 18, not 17.7

+4
source share
2 answers
import math math.ceil(float(177)/10) 
+6
source

You can do this with integer arithmetic:

  items_per_page = 10
 number_of_pages = (x + items_per_page - 1) // items_per_page
+3
source

All Articles