Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calculation to get page count based on # of items

Tags:

python

math

If I have 177 items, and each page has 10 items that means I'll have 18 pages.

I'm new to python and having used any of the math related functions.

How can I calculate 177/10 and then get round up so I get 18 and not 17.7

like image 410
Blankman Avatar asked Jul 31 '10 22:07

Blankman


People also ask

How do I calculate how many pages I need?

To calculate the page count for a 5.5″ × 8.5″ book: 10 pt type – divide your word count by 475. 11 pt type – divide your word count by 425. 12 pt type – divide your word count by 350.

How do you get total pagination pages?

total_items / 10 should give you the number of pages. You also need to consider remainder of the division (total_items % 10). So total pages would be total_items / 10 and 1 more in case remainder is > 0.


1 Answers

import math
math.ceil(float(177)/10)
like image 124
Amber Avatar answered Sep 30 '22 03:09

Amber