7. Negative Decimal Tally 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:
Input four float numbers; they could be positive or negative.
Only add all inputted negative numbers, and print its sum, up to 2 decimal place.
Hint: The previous/latest topic is about if-else-elseif statements, but do we need one here?
Instructions
Input four decimal numbers, they could be positive or negative.
Add all the negative numbers, and print the sum, up to 2 decimal places.
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
n1=input("Enter an interger")
n2=input("Enter an interger")
n3=input("Enter an interger")
n4=input("Enter an interger")
if (n1<0) and (n2<0) and (n3<0) and (n4<0):
print(n1+n2+n3+n4)
Comments
Leave a comment