Answer to Question #235877 in Python for Isabel Cortez

Question #235877

Input


The four numbers


Description


N/A


Constraints


N/A


Sample


N/A


Output


The first four lines will contain message prompts to input the four numbers.

The last line will contain the sum of all positive numbers with two decimal places.


Enter·the·first·number:·12.1

Enter·the·second·number:·-321

Enter·the·third·number:·53.3

Enter·the·fourth·number:·-34

Sum·of·all·positive·numbers·=·65.40


1
Expert's answer
2021-09-11T07:01:32-0400
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 = 65.4

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS