In this python if else program, we will check whether the last digit of a number defined by the user is divisible by 4
Steps to solve the program
- Take a number as input through the user.
- Get the last digit of a number by using %.
- Using an if-else statement check whether the last digit of a number is divisible by 4.
- Print the respective output.
num = 118
last_digit = num%10
if last_digit%4 == 0:
print("The last digit is divisible by 4")
else:
print("The last digit is not divisible by 4")
Output :
The last digit is divisible by 4