Python program to print the square of the number

In this python if else program, we will print the square of the number if it is divided by a certain number ( 11 ). To find the square of a number we need to multiply that number by itself or we can use power operator to get square of the value. e.g. var1**2

Hint:
Use ** to get the square.

Steps to solve the program
  1. Take a number as input through the user.
  2. Use an if-else statement to check whether the given number is divisible by 11 or not.
  3. If yes then print its square.
  4. Else print False.
				
					# Take input through the user
num =  int(input("Enter a number: "))
# Check for division
if num%11 == 0:
    # Print output
    print(num**2)
else:
    # Print output
    print("Number is not divisible by 11")
				
			

Output :

				
					Enter a number: 22
484
				
			
				
					Enter a number: 31
Number is not divisible by 11
				
			

Related Articles

check the given number divided by 3 and 5.

check given number is a prime number or not.

Leave a Comment