Saturday 14 September 2024

Practical - 64 - Write a program in python to input 4 numbers if the addition of all the numbers is multiple of 5 then divide it by 5 otherwise multiply it with 10.

Practical - 64 - Write a program in python to input 4 numbers if the addition of all the numbers is multiple of 5 then divide it by 5 otherwise multiply it with 10.


Ans:

a=int(input("Enter first number: "))

b=int(input("Enter second number: "))

c=int(input("Enter third number: "))

d=int(input("Enter fourth number: "))

sum=a+b+c+d

print("Addition of the numbers=",sum)

if sum%5==0:

    print(sum/5)

else:

    print(sum*10)

 

Output:

Enter first number: 3

Enter second number: 5

Enter third number: 8

Enter fourth number: 9

Addition of the numbers= 25

5.0


OR


Enter first number: 3

Enter second number: 5

Enter third number: 8

Enter fourth number: 7

Addition of the numbers= 23

230


No comments:

Post a Comment