# Python: Round each float in a list of numbers up to the next integer and return the running total of the integer squares

## Python Programming Puzzles: Exercise-80 with Solution

Write a Python program to round each float in a given list of numbers up to the next integer and return the running total of the integer squares.

Input: [2.6, 3.5, 6.7, 2.3, 5.6] Output: [9, 25, 74, 83, 119] Input: [301.1, 401.4, -23.1, 13554122.0, 10201.0101, 10000000.0] Output: [91204, 252808, 253337, 183714223444221, 183714327525025, 283714327525025]

**Pictorial Presentation:**

**Sample Solution:**

**Python Code:**

```
#License: https://bit.ly/3oLErEI
def test(nums):
from math import ceil
running_squares = []
tot = 0
for v in nums:
tot += ceil(v) ** 2
running_squares.append(tot)
return running_squares
nums = [2.6, 3.5, 6.7, 2.3, 5.6]
print("List of numbers:",nums)
print("Round each float of the said list up to the next integer and return the running total of the integer squares:")
print(test(nums))
nums = [301.1, 401.4, -23.1, 13554122.0, 10201.0101, 10000000.0]
print("\nList of numbers:",nums)
print("Round each float of the said list up to the next integer and return the running total of the integer squares:")
print(test(nums))
```

Sample Output:

List of numbers: [2.6, 3.5, 6.7, 2.3, 5.6] Round each float of the said list up to the next integer and return the running total of the integer squares: [9, 25, 74, 83, 119] List of numbers: [301.1, 401.4, -23.1, 13554122.0, 10201.0101, 10000000.0] Round each float of the said list up to the next integer and return the running total of the integer squares: [91204, 252808, 253337, 183714223444221, 183714327525025, 283714327525025]

**Flowchart:**

**Python Code Editor :**

**Have another way to solve this solution? Contribute your code (and comments) through Disqus.**

**Previous:** Find the largest negative and smallest positive numbers.

**Next:** Calculate the average of the numbers a through b rounded to nearest integer, in binary.

**What is the difficulty level of this exercise?**

Test your Programming skills with w3resource's quiz.

**Weekly Trends**- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join