0% found this document useful (0 votes)
9 views1 page

Python Assignment 7 G3

The document outlines a Python programming lab with a series of tasks to be implemented using functions. These tasks include finding factorials, reversing numbers, identifying prime factors, printing twin primes, calculating the product of digits, checking for palindromes, finding maximum values, converting decimal to binary, and identifying perfect and amicable numbers. Users are instructed to accept inputs only from the user for all functions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views1 page

Python Assignment 7 G3

The document outlines a Python programming lab with a series of tasks to be implemented using functions. These tasks include finding factorials, reversing numbers, identifying prime factors, printing twin primes, calculating the product of digits, checking for palindromes, finding maximum values, converting decimal to binary, and identifying perfect and amicable numbers. Users are instructed to accept inputs only from the user for all functions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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

You might also like