Answer to Question #292648 in Python for haow

Question #292648

Decimal Galore

by CodeChum Admin

We've been dealing with integers too much, it's time for decimals to shine!


Instructions:

  1. Input five decimal numbers in one line.
  2. Print out the decimal numbers in one line, separated by spaces, and make sure you only print up to 1 decimal place.
  3. Add the first four decimal numbers and check if their sum is greater than the fifth decimal number. Print out "Yes" if they are.

Input

A line containing five decimal numbers separated by a space.

1.1·1.2·1.3·1.4·1.1

Output

The first line contains all the inputted decimal numbers separated by a space.

The second line contains a string which is the result.

1.1·1.2·1.3·1.4·1.1
Yes
1
Expert's answer
2022-02-05T02:04:37-0500
def check(arr2):
  if len(arr2)<5 or len(arr2)>5:
    print("MUst be 5 decimal numbers")
    return
  print("Output")
  if arr2[0]+arr2[1]+arr2[2]+arr2[3]>arr2[4]:
    print(*arr2)
    print('Yes')
  else:
    print(*arr2)
    
arr1= input("Enter 5 decimal numbers separated by space: ").split()
arr2=[]
for i in arr1:
  arr2.append(round(float(i),1))
check(arr2)

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