Computer Science
Write a program to compute (a + b)3 using the formula a3 + b3 + 3a2b + 3ab2
Python
Python Data Handling
54 Likes
Answer
a = int(input("Enter a: "))
b = int(input("Enter b: "))
res = a ** 3 + b ** 3 + 3 * a ** 2 * b + 3 * a * b ** 2
print("Result =", res)
Output
Enter a: 3
Enter b: 5
Result = 512
Answered By
23 Likes
Related Questions
Write a program to calculate the area of an equilateral triangle. (area = (√3 / 4) * side * side).
Write a program to calculate amount payable after compound interest.
Write a program to input the radius of a sphere and calculate its volume (V = 4/3πr3)
Write a program to calculate amount payable after simple interest.