Input
The first number, second number, third number, fourth number and fifth number contains:
Description
N/A
Constraints
This may be a decimal number.
Sample
N/A
Output
The first line will contain a message prompt to input the first number.
The second line will contain a message prompt to input the second number.
The third line will contain a message prompt to input the third number.
The fourth line will contain a message prompt to input the fourth number.
The fifth line will contain a message prompt to input the fifth number.
The last line contains the sum of all negative numbers rounded off and displayed with 2 decimal places.
Enter·the·first·number:·34
Enter·the·second·number:·43.5
Enter·the·third·number:·-53.24
Enter·the·fourth·number:·56.3
Enter·the·fifth·number:·-10.32
Sum·of·all·negative·integers·=·-63.56
F1=float(input("Enter the first number: "))
F2=float(input("Enter the second number: "))
F3=float(input("Enter the third number: "))
F4=float(input("Enter the fourth number: "))
F5=float(input("Enter the fifth number: "))
if F1<0:
F1=F1
else:
F1=0
if F2<0:
F2=F1+F2
else:
F2=F1
if F3<0:
F3=F2+F3
else:
F3=F2
if F4<0:
F4=F4+F3
else:
F4=F3
if F5<0:
F5=F5+F4
else:
F5=F4
print("Sum of all negative integers=",F5)
Comments
Leave a comment