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
#creating a varieble to input our numbers
numbers = input("Enter four float numbers which are separated with a space:")
N = numbers.split(" ")
sum_of_neg = 0.0
#creating a loop and condition to find the sum
for i in N:
x = float(i)
if (x < 0):
sum_of_neg += x
print("{:.2f}".format(sum_of_neg))
#This code is written by expert Suhrob Umarov
Comments
Leave a comment