Python: Compute the sum of the three lowest positive numbers from a given list of numbers
Sum of Three Lowest Positives
Write a Python program to compute the sum of the three lowest positive numbers from a given list of numbers.
Sample Solution:
Python Code:
Sample Output:
Original list of numbers: [10, 20, 30, 40, 50, 60, 7] Sum of the three lowest positive numbers of the said array: 37 Original list of numbers: [1, 2, 3, 4, 5] Sum of the three lowest positive numbers of the said array: 6 Original list of numbers: [0, 1, 2, 3, 4, 5] Sum of the three lowest positive numbers of the said array: 6
Explanation:
Here is a breakdown of the above Python code:
- Function Definition:
- The code defines a function named "sum_three_smallest_nums()" that takes a list of numbers (lst) as an argument.
- List Comprehension:
- The function uses list comprehension to filter positive numbers from the input list.
- Sorting and Summing:
- The positive numbers are sorted, and the sum of the three smallest positive numbers is calculated using slicing ([:3])
Visual Presentation:
Flowchart:

For more Practice: Solve these Related Problems:
- Write a Python program to identify the three smallest positive numbers in a list and calculate their sum.
- Write a Python program to sort a list and sum the first three positive integers found.
- Write a Python program to filter positive numbers from an array, sort them, and compute the sum of the three lowest.
- Write a Python program to determine the sum of the three smallest positive values using a min-heap data structure.
Go to:
Previous: Write a Python program that accept two strings and test if the letters in the second string are present in the first string.
Next: Write a Python program to replace all but the last five characters of a given string with "*" and returns the new string.
Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.