Python Assignment
Python Assignment
1. Write a program to read the numbers until -1 is encountered. Find the avaearge of positive
numbers and negative numbers entered by user.
2. WAP to find the given number is an Armstrong number or not.
3. WAP to enter a number and then calculate the sum of digits.
4. WAP to find reverse of a number.
5. WAP to print following patterns
a)
1
22
333
4444
55555
b)
1
121
12321
1234321
7. WAP to create a list of numbers in the range 1 to 10. Then delete all the even numbers from
the list and print the final list.
8. Write a program to remove all duplicates from a list.
9. WAP to generate fibonacci sequence and store in a list. Then find the sum of the even-valued
terms.
10. WAP that scans an email address and forms a tuple of user name and domain.
11. WAP to store a sparse matrix as a dictionary
Output: {(0,3):8, (2,3): 5, (1,0):3, (1,4): 1}
Sparse Matrix
00080
30001
00050
12. WAP that has a dictionary of names of students and a list of their marks in 4 subjects.
Create another dictionary from this dictionary that has a name of the students with their total
marks. Find the student that have scored highest marks with his/her marks.
13. WAP that combines the lists to a dictionary.
14. WAP to encrpt and decrypt message using caesar cipher
encryption function, e(x) = (x+key)% 26
decryption function, e(x) = (x-key)% 26