Skip to main content
Skip to content

Lists & Objects · Beginner

List Sum, Average, Min and Max in Hinglish

Sum, average, min, max and an even count in one pass.

The program

Edit anything and press Run. The output below was produced by running this exact code.

Expected output

Press Run to try it

Data: [12, 45, 7, 23, 56, 89, 35]Sum: 267 | kul() se: 267Average: 38.14Min: 7 | Max: 89Even numbers: 2Sorted: [7, 12, 23, 35, 45, 56, 89]

How it works

One loop does all the work. The running total grows by each item, sabse_chhota and sabse_bada start at the first item and are replaced whenever something smaller or bigger turns up, and even_count counts items with no remainder when divided by 2.

The average is rounded to two decimal places with a common trick: multiply by 100, round, then divide by 100.

kul and chhanto are built-ins that give the same sum and a sorted copy in one call — handy for checking the hand-written loop.