by CodeChum Admin
We've been giving positive numbers too much attention lately, it's time to let negative numbers take the spotlight this time!
Instructions:
Instructions
Input
A line containing four decimals/floats separated by a space.
-30.22·10.5·-2.2·-1.8
Output
A line containing a negative decimal/floats with two decimal places.
-34.22
nums=input("Enter four decimals/floats separated by a space:")
n=nums.split(" ")
sum_neg=0.0
for i in n:
x=float(i)
if(x<0):
sum_neg+=x
print("{:.2f}".format(sum_neg)
Comments
Leave a comment