This document contains an assignment with 8 questions related to Python lists. Question 1 asks to differentiate between list and string types, and list methods append vs extend, pop vs del. Questions 2-4 ask to write programs to search, find maximum, and count frequencies in lists. Question 5 asks to identify the appropriate list method for tasks like deletion and addition. Questions 6-8 predict the output of code samples involving list slicing, indexing, concatenation and other operations.
This document contains an assignment with 8 questions related to Python lists. Question 1 asks to differentiate between list and string types, and list methods append vs extend, pop vs del. Questions 2-4 ask to write programs to search, find maximum, and count frequencies in lists. Question 5 asks to identify the appropriate list method for tasks like deletion and addition. Questions 6-8 predict the output of code samples involving list slicing, indexing, concatenation and other operations.
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2
Assignment
Q1. Differentiate between
a) List and String b) append and extend c) pop and del d) pop and remove Q2. Write a program to search an element in a list. Q3. Write a program to find the maximum element in the list. Q4. Write a program to count the frequency of given element in the list. Q5. Write the most appropriate method to perform the given task? a) Delete a given element from the list b) Delete 4th element from the list c) Add an element in the end of the list d) Add an element in the beginning of the list e) Add an element of a list in the end of the list Ans: (a) remove (b)pop() (c) append() (d) insert (e) insert() (f) extend() Q6. Predict the output: List1=[‘c’,’o’,’m’,’p’,’u’,’t’,’e’,’r’] List1[3:4] = [ ] print(List1) List1[2:6] = [ ] Print(List1) Ans: ['c', 'o', 'm', 'u', 't', 'e', 'r'] ['c', 'o', 'r']