satya

Wednesday, October 7, 2020

Program 13

                                                                                 

Program-13

Write a program that asks the user for an integer and creates a list that consists of the factors of that integer.


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

l=[]

for i in range(1,num+1):

    if(num%i==0):

        l.append(i)

print("factors of %d is="%(num),l)

OUTPUT:

>>> 

===== RESTART: D:/old/r19 lab-python/13.py =========

Enter the Number:45

factors of 45 is= [1, 3, 5, 9, 15, 45]

>>> =====RESTART: D:/old/r19 lab-python/13.py =======

Enter the Number:16

factors of 16 is= [1, 2, 4, 8, 16]

>>> 


No comments:

Post a Comment

Program 30

                                                                         Program 30 Write a Python class to implement pow(x, n). class Pow1:...