Python Programming Lab
Note: Implement all programs using functions and accept inputs from user only.
1. Write a function to find the factorial of a given number.
2. Write a function to reverse a given number.
3. Write a function to find out the prime factors of a number. Example: prime factors
of 56 - 2, 2, 2, 7.
4. Write a program to print twin primes less than 1000. If two consecutive odd
numbers are both prime then they are known as twin primes.
5. Write a function prodDigits() that inputs a number and returns the product of digits of
that number.
6. Write a function to check whether a number is palindrome or not.
7. Define a function that accepts 3 values and returns the maximum of three numbers.
8. Write a function that converts a decimal number to a binary number.
9. A number is called perfect if the sum of proper divisors of that number is equal to the
number. For example 28 is the perfect number, since 1+2+4+7+14=28. Write a program to
print all the perfect numbers in a given range.
10. Two different numbers are called amicable numbers if the sum of the proper divisors of
each is equal to the other number. Write a function to print pairs of amicable numbers in a
range.
For example 220 and 284 are amicable numbers.
Sum of proper divisors of 220 = 1+2+4+5+10+11+20+22+44+55+110 = 284
Sum of proper divisors of 284 = 1+2+4+71+142 = 220