Practical - 63 - Write a program in python to input 4 numbers if the multiplication of the numbers is odd then calculate its square otherwise calculate its cube.
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: "))
m=a*b*c*d
print("Multiplication of the numbers=",m)
if m%2==1:
print("Square=",m**2)
else:
print("Cube=",m**3)
Output:
Enter first number: 3
Enter second number: 4
Enter third number: 5
Enter fourth number: 6
Multiplication of the numbers= 360
Cube= 46656000
OR
Enter first number: 1
Enter second number: 3
Enter third number: 5
Enter fourth number: 3
Multiplication of the numbers= 45
Square= 2025
No comments:
Post a Comment