Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Find Factors of a Number using While Loop

print("Enter the Number: ")
num = input()

num = int(num)
print("
Factors of", num)

i = 1
while i<=num:
    if num%i==0:
        print(i)
    i = i+1
Comment

Find Factors of a Number Using for Loop

print("Enter a Number: ", end="")
try:
    num = int(input())

    print("
Factors of " +str(num)+ " are: ", end="")
    for i in range(1, num+1):
        if num % i == 0:
            print(i, end=" ")
    print()
except ValueError:
    print("
Invalid Input!")
Comment

Find Factors of a Number using While Loop

print("Enter the Number: ")
num = input()

num = int(num)
print("
Factors of", num)

i = 1
while i<=num:
    if num%i==0:
        print(i)
    i = i+1
Comment

Find Factors of a Number Using for Loop

print("Enter a Number: ", end="")
try:
    num = int(input())

    print("
Factors of " +str(num)+ " are: ", end="")
    for i in range(1, num+1):
        if num % i == 0:
            print(i, end=" ")
    print()
except ValueError:
    print("
Invalid Input!")
Comment

PREVIOUS NEXT
Code Example
Python :: Code Example to Check the type of None object 
Python :: Command to import the Schema interface from voluptuous 
Python :: link prettify in beautifulsoup 
Python :: Simple Python Permutation to get the output is by making a list and then printing it 
Python :: add Elements to Python list Using extend() method 
Python :: Code to find maximum number using if else 
Python :: how to return and use a single object in custom template filters django 
Python :: numpy find most distant elements in array 
Python :: stop level of the broker 
Python :: testing grepper python 
Python :: pandas version for python 3.9 
Python :: vortex identification 
Python :: automate ms word with python 
Python :: how to check weight value in keras neurons 
Python :: Explaining async session in requests-html 
Python :: Python NumPy transpose Function Example with use of tuples 
Python :: display colors in python console 
Python :: k means em algorithm program in python 
Python :: Python NumPy vstack Function Example with 2d array 
Python :: catch all event on socketio python 
Python :: if statment with logical or operator for multiple varaibles 
Python :: palindrome rearrange 
Python :: beaglebone install python 3.7 
Python :: python subprocess redirect a file 
Python :: list of pdf download python selenium 
Python :: python truncade number 
Python :: QDateEdit.date().toString("MMMM dd, yyyy") does not display months in English 
Python :: opencv2.3 
Python :: seaborn colorbar labelsize 
Python :: Repetition in code for routes in Flask (or Bottle) 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =