-3

Guys i want to round the given numbers to the nearest multiple of 10. e.g. 15 should be rounded to 20 whereas 14 should be rounded to 10. After rounding the numbers, i want to find their sum.

Sample input is like (a list): [2, 18, 10]

Sample output: 30

Sample 2:

[10, 20, 1, 1]

Output : 30

wjandrea
  • 28,235
  • 9
  • 60
  • 81
manish
  • 55
  • 1
  • 8

1 Answers1

-1

Using NumPy:

import numpy as np

numbers = [1,10,20,1]
np.around(numbers, decimals=-1).sum()

gives 30.

alex
  • 10,900
  • 15
  • 70
  • 100