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
- Take a number as input through the user.
- Use an if-else statement to check whether the given number is divisible by 11 or not.
- If yes then print its square.
- 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
- Python program to check given number is a prime number or not.
- Python program to check given number is odd or even.
- Python program to check a given number is part of the Fibonacci series from 1 to 10.
- Python program to check authentication with the given username and password.
- Python program to validate user_id in the list of user_ids.
- Python program to print a square or cube if the given number is divided by 2 or 3 respectively.