Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

perfect number in python

def perfect_number(n):
    sum = 0
    for x in range(1, n):
        if n % x == 0:
            sum += x
    return sum == n
print(perfect_number(6))
Comment

perfect number program in python

n = int(input("Enter any number: "))sum1 = 0for i in range(1, n):if(n % i == 0):sum1 = sum1 + iif (sum1 == n):print("The number is a Perfect number!")else:print("The number is not a Perfect number!")
Comment

perfect number code python

def perfect(n):
	f=[]
    for i in range(1,n):
    	if n%i==0:
          f.append(i)
    if sum(f)==n:
    	print(n," is perfect")
    else:
    	print("Not perfect")
n=eval(input("Enter number:"))
perfect(n)
Comment

perfect numbers python

n=int(input("Enter a Number : "))
c = 0
for i in range(1, n):
    if n % i == 0:
        c = c + i
if c == n:
    print(n, "The number is a Perfect number!")
else:
    print(n, "The number is not a Perfect number!")
Comment

PREVIOUS NEXT
Code Example
Python :: jupiter lab 
Python :: service 
Python :: python how to print 
Python :: dfs 
Python :: hash table data structure python 
Python :: gaussian 
Python :: string pythhon 
Python :: .extend python 
Python :: python typing union 
Python :: pandas idxmax 
Python :: cudart64_110.dll not found 
Python :: oops python 
Python :: range 
Python :: hash table python 
Python :: how to make a label in python 
Python :: what is thread in python 
Python :: Python Map Function Syntax 
Python :: pandas set index 
Python :: how to change title font size in plotly 
Python :: Adding column to CSV Dictreader 
Python :: python aus liste tuple machen 
Python :: supercharged python 
Python :: python hlaf of list 
Python :: python sort list by length of sublist 
Python :: explained_variance_ratio kernel pca 
Python :: how to add extra str in python?phython,add,append,insert 
Python :: databases not showing in odoo 13 
Python :: What is StringIndexer , VectorIndexer, and how to use them? 
Python :: "not equal to" python symbol 
Python :: table is not creating in django 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =