0% found this document useful (0 votes)
2 views9 pages

Python Programs

The document outlines a series of programming tasks in Python, including calculations for sums of even and odd digits, checking for prime and palindrome numbers, finding factorials, GCD, LCM, and various special number checks. It also includes string manipulation tasks, such as counting occurrences of characters and replacing words, as well as list and tuple operations. Each task is presented as a 'Write a Program' (W.A.P) instruction, providing clear objectives for coding exercises.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views9 pages

Python Programs

The document outlines a series of programming tasks in Python, including calculations for sums of even and odd digits, checking for prime and palindrome numbers, finding factorials, GCD, LCM, and various special number checks. It also includes string manipulation tasks, such as counting occurrences of characters and replacing words, as well as list and tuple operations. Each task is presented as a 'Write a Program' (W.A.P) instruction, providing clear objectives for coding exercises.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

1. W.A.P to calculate the sum of even digits and sum of odd digits.

2. W.A.P to check whether a given number is a prime number.


3. Write a program to check whether a given number is a palindrome
Eg. 121,3553

4. W.A.P to find the factorial of 5

5. W.A.P to find the GCD of two numbers


Eg: 12,8 GCD=4
6. W.A.P to find the LCM of two numbers
Eg: 12,8 lcm=24
7. W.A.P to check if a given number is a spy number or not.(sum of its digits is equal to the product of
the digits)
Eg: 123
1+2+3=6
1*2*3=6

8. W.A.P to check if a number is a special number or not. (sum of its digits plus product of digits is
equal to original number).Eg.59
(5+9)=(5*9)=59
9.W.A.P to check if a number is niven number /Harshad number.A number which is divisible by the
sum of its [Link].156
1+5+6=12. 156 is divisible by 12.

10. W.A.P to check whether a given number is a Armstrong number. A number is equal to the sum of
the cube of its digits.
Eg: 153
13+53+33=153
11. W.A.P to count and print the frequency of an element 2 in the list l1=[2,1,3,1,2,1]

12. W.A.P to check whether a given string is a palindrome.


Eg: mam,madam
13. 1)Create a string with the following content:”python programming is fun!”
2) Count the number of occurrence of the letter ‘o’ in the string
3) Replace the word ‘programming’ with ‘coding’ in the string

14. Write a python program that perform the following operations on a list of integers
1. create a list of integers.[5,15,25,35,45]
2. Append the integer 55 to the list.
3. Insert the integer 20 at index1
4. Remove the integer 35 from the list
5. Find the index of the integer 25 and print it.
6. print the final list.

15. Write a python program that creates a tuple with elements from a list. Your program should do
the following.
1. create a list with multiple elements
2. converts a list to a tuple
3. print the tuple and demonstrate accessing an element of a tuple.
16. Write a python program to count the number of vowels in a given string. Your program should do
the following.
1. Define a string
2. traverse the string and count the vowels(a,e,i,o,u) using a loop
3. print the total count of vowels
17. W.A.P to create a list of integers and print the odd and even numbers.

You might also like