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

print perfect number in python

a=int(input("Give a number: "))
sum=0
for i in range(1,a):
  if a%i==0:
    sum=sum+i
if sum==a:
  print(a,"is a perfect number")
else:
  print(a,"is not a perfect number")
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 :: image in cv2 
Python :: how to find the most frequent value in a column in pandas dataframe 
Python :: sklearn plot confusion matrix 
Python :: python distance between coordinates 
Python :: save and load a dictionary python 
Python :: cv2 draw box 
Python :: python flask query params 
Python :: dislike_count 
Python :: join list with comma python 
Python :: how to open an external file in python 
Python :: python - give a name to index column 
Python :: install googlesearch for python 
Python :: stripping /n in a readlines for a pytgon file 
Python :: conda python 3.8 
Python :: python requirments.txt 
Python :: height width image opencv 
Python :: python how to get number of strings in a list 
Python :: python split path at level 
Python :: hello world python 
Python :: how to use rmse as loss function in keras 
Python :: jupyter notebook pass python variable to shell 
Python :: average value of list elements in python 
Python :: generate a list of random numbers python 
Python :: sum of all nan values pandas 
Python :: django admin prefetch_related 
Python :: f-string ponto decimal python 
Python :: python import from other folder outside folder 
Python :: df dropna ensure that one column is not nan 
Python :: set os environment variable python 
Python :: how to update sklearn using conda 
ADD CONTENT
Topic
Content
Source link
Name
5+8 =