onlinecode

How to check if a number is multiple of 10 in Python

How to check if a number is multiple of 10 in Python

In this post we will give you information about How to check if a number is multiple of 10 in Python. Hear we will give you detail about How to check if a number is multiple of 10 in PythonAnd how to use it also give you demo for it if it is necessary.

we are going to learn about how to check if a given number is multiple of 10 or not in Python.

Consider, we have a following number:

a = 100

To find if a above number 100 is a multiple of 10 the number should be divided by 10 and the remainder is 0.

Using % Modulo operator

To check if a number is multiple of 10 or not, we can use the % modulo operator in Python.

The modulo % operator returns the remainder of two numbers 100 % 10, so if we get a remainder 0 then the given number is a multiple of 10.

Here is an example:

a = 100if a % 10 == 0 :   print("a is multiple of 10")else:   print("a is not a muliple of 10")

Output:

"a is multiple of 10"

In the above code we have added a % 10 == 0 in if condition, so 100 is divided by 10 and returns the remainder 0 then it prints the output “a is multiple of 10”.

Example 2 :

b = 300if b % 10 == 0 :   print("b is multiple of 10")else:   print("b is not a muliple of 10")

Output:

"b is multiple of 10"

Checking if a number is not a multiple of 10

To check if a number is not a multiple of 10, we can use the modulo operator % but the remainder of first number by second number is not equal to 0.

Here is an example:

if (23 % 10 != 0):    print ("23 is not a multiple of 10")

In the above code, 23 is divided by 10 and returns the remainder 3. So the given number is not a multiple of 10.

Hope this code and post will helped you for implement How to check if a number is multiple of 10 in Python. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Exit mobile version