find number of factors of a number python code example

Example 1: number of digits in a number python

n = 1234 //Any Random Number
digits = len(str(n)) //Saves the number of digits of n into the variable digits

Example 2: to find factors of a number in python

# Python Program to find the factors of a number

# This function computes the factor of the argument passed
def print_factors(x):
   print("The factors of",x,"are:")
   for i in range(1, x + 1):
       if x % i == 0:
           print(i)

num = 6

print_factors(num)