Example HTML page

A Python program to solve (a+b)*(a+b)

Today i am posting a python program to solve the expression (a+b)*(a+b).

Program

a, b = 5, 7
result = a * a + 2 * a * b + b * b
print("({} + {}) ^ 2) = {}".format(a, b, result))

Output

(5 + 7) ^ 2) = 144

Here we initialized two variables ‘a’ and ‘b’. The equation (a+b)*(a+b) can be written in the form of (a+b)2. So the equation can be written as a * a + 2 * a * b + b * b. The output is stored in the variable result. Finally it prints the result of (a+b)*(a+b).

Similarly we can also write a program to solve the equation (a+b+c)2

a, b, c = 5, 7 ,2
result = a * a + b * b + c * c +2 * a * b + 2 * b * c + 2 * c * a
print("({} + {} + {}) ^ 2) = {}".format(a, b, c, result))

Output

(5 + 7 + 2) ^ 2) = 196

Similarly try for the following equations.

  1. (a-b)(b-a)
  2. (a+b)3
  3. (a2+b2)
  4. (a-b)3
Example HTML page

Leave a Reply

Your email address will not be published. Required fields are marked *

Pin It on Pinterest