Answer to Question #274151 in Python for mica

Question #274151
  1. Input four float numbers; they could be positive or negative.
  2. Only add all inputted negative numbers, and print its sum, up to 2 decimal place.
1
Expert's answer
2021-12-01T18:38:07-0500
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)

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