## Python 3 Script to Check Whether the Number is Perfect or Not Using For and While Loop and Functions Full Project For Beginners Welcome folks today in this blog post we will be `whether the number is perfect or not using for loop and while loop and functions in python.`All the full source code of the application is given below.

# Get Started

In order to get started you need to make an `app.py` file and copy paste the following code

`Using For Loop`

`app.py`

``````# Python Program to find Perfect Number using For loop

Number = int(input(" Please Enter any Number: "))
Sum = 0
for i in range(1, Number):
if(Number % i == 0):
Sum = Sum + i
if (Sum == Number):
print(" %d is a Perfect Number" %Number)
else:
print(" %d is not a Perfect Number" %Number)``````

See also  Python 3 Automation Script to Delete All Files Inside a Directory Older than X Days Using OS and Time Modules Full Project For Beginners

`Using While Loop`

`app.py`

``````# Python Program to find Perfect Number using While loop

Number = int(input(" Please Enter any Number: "))
i = 1
Sum = 0
while(i < Number):
if(Number % i == 0):
Sum = Sum + i
i = i + 1
if (Sum == Number):
print(" %d is a Perfect Number" %Number)
else:
print(" %d is not the Perfect Number" %Number)``````

`Using Functions`

`app.py`

``````# Python Program to find Perfect Number using Functions

def Perfect_Number(Number):
Sum = 0
for i in range(1, Number):
if(Number % i == 0):
Sum = Sum + i
return Sum

# Taking input from the user
Number = int(input("Please Enter any number: "))
if (Number == Perfect_Number(Number)):
print("\n %d is a Perfect Number" %Number)
else:
print("\n %d is not a Perfect Number" %Number)``````

See also  Python 3 Tkinter Temperature Converter Celsius to Fahrenheit GUI Desktop App Full Project For Beginners

Now if you execute the `python` script by typing the below command as shown below

`python app.py` 