The first three lines will contain message prompts to input the three decimal numbers.
The last line contains the result in two decimal places.
list1 = []
for i in range(4): n = eval(input('Enter no here: ')) if n > 0: list1.append(n)
print('Sum of all positive integers = {}'.format(round(sum(list1), 2)))
Enter no here: 12.1
Enter no here: -321
Enter no here: -34
Enter no here: 53.3
Sum of all positive integers = 6
Comments
Leave a comment