In this video, you’ll learn how to check whether a number is a Perfect Number in Python using a simple and efficient approach with list comprehension.
A Perfect Number is a positive integer that is equal to the sum of all its proper divisors, excluding the number itself.
👨🏫 What You’ll Learn in This Video:
What is a Perfect Number?
Real examples: 28 (perfect), 16 (not perfect)
How to find proper divisors using range() and list comprehension
Using the modulus operator to filter divisors
Writing a Python function is_perfect(n)
Taking user input and checking the result with if-else
Performing a dry run to understand the logic step-by-step
📌 Example Outputs:
Input: 28 → Output: 28 is a perfect number
Input: 16 → Output: 16 is not a perfect number