6.
Perfect Number
A number is perfect if the sum of its proper divisors (excluding itself) equals the number.
num = int(input('Enter a number: '))
sum_div = sum(i for i in range(1, num) if num % i == 0)
if sum_div == num:
print('Perfect Number')
else:
print('Not a Perfect Number')
7. Palindrome Number
Check if a number reads the same forward and backward.
num = input('Enter a number: ')
if num == num[::-1]:
print('Palindrome')
else:
print('Not Palindrome')
8. Harshad Number
A number is Harshad if it is divisible by the sum of its digits.
num = int(input('Enter a number: '))
sum_digits = sum(int(d) for d in str(num))
if num % sum_digits == 0:
print('Harshad Number')
else:
print('Not a Harshad Number')
9. Decimal to Binary
Convert a decimal number to binary using bin() or custom method.
num = int(input('Enter decimal number: '))
print('Binary:', bin(num)[2:])
10. Binary to Decimal
Convert binary to decimal using int() with base 2.
binary = input('Enter binary number: ')
print('Decimal:', int(binary, 2))