Check whether the last digit of a number is divisible by 4

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
  1. Take a number as input through the user.
  2. Get the last digit of a number by using %.
  3. Using an if-else statement check whether the last digit of a number is divisible by 4.
  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
				
			

Related Articles

check the student’s eligibility to attend the exam based on his/her attendance.

display 1/0 if the user gives Hello/Bye as output.

Leave a Comment