Question paper
List Questions
1. what is the output of the code?
list1
= [12, 32, 65, 26, 80, 10]
list1.sort()
print(list1)
2. list1
= [12, 32, 65, 26, 80, 10]
sorted(list1)
print(list1)
3. list1=[1,2,3,4,5]
print(list1[len(list1)-1)
4. Consider the following list myList. What will be
the elements of myList after the following two operations :
myList=[10,20,30,40]
i. myList.append([50,60])
print(myList)
ii. myList.extend([80,90])
print(myList)
5. Difference between append() and extend() functions
of list?
6. The record of a student(Name,Roll_No, Marks in five
subjects and percentage of marks) is stored in the following list:
stRecord = [‘Raman’ , ‘A-36’ , [56,98,99,72,69] ,
78.8]
Write python statements to retrieve the following
information from the list stRecord.
a) percentage of the student
b) marks in the fifth subject
c) maximum marks of the student
d)Roll_no of the student
e) Change the name of the student from ‘Raman’ to
‘Raghav’
-----------------------------------------------------------------------------------------------------------------------
Dictionary Questions
1. What is Python Dictionary and its characteristics of python Dictionary?
2. Give example code for traversing a Dictionary?
3. How to append value and change the existing value in python Dictionary?
4. Write the output of the following:
m
= {1 : “Jan”, 2 : ‘Jun’, 3 : ‘Aug’}
print(m[1])
print(m[“jan”])
5.
Write a program in python to display the maximum and minimum value in
dictionary.
d1
= {1 : 21, 2 : 90, 3 : 50}
6. Explain about any 6 methods in dictionary with example
code. Below given dictionary for your reference
A = {1 : "One", 2 : "Two", 3 : "Three"}
B = {'A' : "Apple", 'B' :
"Bat", 'C' : "Cat", 'D' : "Doll"}
7. Explain the following in reference to dictionary.
1. del statement 2. pop() method 3.values() 4.keys()
8. Write the output of the following:
d={1:
‘Amit’, 2: ‘Sumit’, 5: ‘Kavita’}
print(len(d))
print(d.get(2))
d.pop(5)
9. Write a program to create a dictionary M , which stores the marks of the students of class
with roll numbers as the keys and marks as the values.Get the number of students as input?
Comments
Post a Comment