Calculate expression in Python
input() - Question 15
In this question, we will see how to input the values in the variable a, b in Python programming using the input() function and find the result of the expression a2+2ab+b2. To know more about input() function click on the input() function lesson.
Q15) Write a program in Python to input the values in the variable a, b and find the result of the expression a2+2ab+b2.
Program
a=int(input('Enter value of a '))
b=int(input('Enter value of b '))
c=(a*a)+(2*a*b)+(b*b)
print('Result={}'.format(c))
Output
Enter value of a 2 Enter value of b 3 Result=25