Assignment - Basics of Python
Assignment - Basics of Python
Python Assignment
-----------------------------------------------------------------------------------------------------------------------------
Q1. L is a list defined as L= [11, 12, 13, 14].
(i) WAP to add 50 and 60 to L.
(ii) WAP to remove 11 and 13from L.
(iii) WAP to sort L in ascending order.
(iv) WAP to sort L in descending order.
(v) WAP to search for 13 in L.
(vi) WAP to count the number of elements present in L.
(vii) WAP to sum all the elements in L.
(viii) WAP to sum all ODD numbers in L.
(ix) WAP to sum all EVEN numbers in L.
(x) WAP to sum all PRIME numbers in L.
(xi) WAP to clear all the elements in L.
(xii) WAP to delete L.
Q3. S1 is a set defined as S1= [10, 20, 30, 40, 50, 60].
S2 is a set defined as S2= [40, 50, 60, 70, 80, 90].
(i) WAP to add 55 and 66 in Set S1.
(ii) WAP to remove 10 and 30 from Set S1.
(iii) WAP to check whether 40 is present in S1.
(iv) WAP to find the union between S1 and S2.
(v) WAP to find the intersection between S1 and S2.
(vi) WAP to find the S1 - S2.
Q5. WAP to create two lists of 10 random numbers between 10 and 30; Find
(i) Common numbers in the two lists
(ii) Unique numbers in both the list
(iii) Minimum in both the list
(iv) Maximum in both the list
(v) Sum of both the lists
Q6. WAP to create a list of 100 random numbers between 100 and 900. Count and print the:
(i) All odd numbers
(ii) All even numbers
(iii) All prime numbers
Q9. Write to the file 100 random strings whose length between 10 and 15.
Q10. Write to the file all prime numbers between 600 and 800.
Q12. WAP to sort following number of elements in a list, calculate time taken and plot the graph.
Number of elements in list Time Taken
5k T1
10k T2
15k T3
20k T4
25k T5
Q13. WAP to create a dictionary of student marks in five subjects and you have to find the student
having maximum and minimum average marks.