KnowledgeBoat Logo

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