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 :: pandas convert date column to year and month 
Python :: all alphabets 
Python :: seaborn heatmap text labels 
Python :: run sql query on pandas dataframe 
Python :: python order 2d array by secode element 
Python :: csv write without new line 
Python :: find nan value in dataframe python 
Python :: python code to plot pretty figures 
Python :: remove n string 
Python :: roll longitude about zero 
Python :: pandas display only certain columns 
Python :: emoji in python 
Python :: how to log ip addresses in django 
Python :: python socket recv timeout 
Python :: python set symmetric difference 
Python :: Violin Plots, Python 
Python :: make first row column names pandas 
Python :: print() in python 
Python :: how to print all rows in pandas 
Python :: printing with format float to 2 decimal places python 
Python :: selenium zoom out python 
Python :: pyodbc ms access 
Python :: python writeline file 
Python :: WARNING: Ignoring invalid distribution -ip 
Python :: how to import iris dataset 
Python :: plot distribution seaborn 
Python :: how to create a loop in python turtle 
Python :: 2 numbers after comma python 
Python :: pip install vlc 
Python :: how to input comma separated int values in python 
ADD CONTENT
Topic
Content
Source link
Name
1+3 =