0% found this document useful (0 votes)
36 views2 pages

assignment list and dictionery

The document contains a series of Python code snippets and questions regarding their outputs, including list manipulations, the use of the len() function, and loops. It also includes questions about the behavior of certain operations on lists and strings. The document is instructional in nature, aimed at testing knowledge of Python programming.

Uploaded by

dgpguru
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)
36 views2 pages

assignment list and dictionery

The document contains a series of Python code snippets and questions regarding their outputs, including list manipulations, the use of the len() function, and loops. It also includes questions about the behavior of certain operations on lists and strings. The document is instructional in nature, aimed at testing knowledge of Python programming.

Uploaded by

dgpguru
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
You are on page 1/ 2

1. Write the output of the given Python code.

list1 = [‘physics’, ‘chemistry’, 1997, 2000];


list2 = [1,2,3,4,5,6, 7];
print “list1[0]”, list1[0]
2. Write the output of the given Python code.
listl = [‘physics’, ‘chemistry’, 1997,2000];
list2 = [1,2, 3,4,5, 6, 7];
print “list2[l:5[ :”, list2[l:5]
3.What is the use of len(list)) in Python?
4. What is output
listl = [‘physics’, ‘chemistry’, 1997, 2000];
print “Value available at index 2 :”
print list[2];
list[2] = 2001;
print “New value available at index 2 :”
print list [2];
5.Write the output of the given Python code :
list1, list2 = [123, ‘xyz’], [456, ‘abc’]
print cmpt(list1, list2);
print cmp(list2, list1);
list3 = list2 + [786];
print cmp(list2, list3)
5.Write the output of the given Python code :
aList = [123, ‘xyz’, ‘zara’, ‘abc’, 123];
bList = [2009, ‘manni’];
aList.extend (bList)
print “Extended List :”, aList;
6.Write the output of the given python code :
aList1 = [123, ‘xvz’, zara’, abc’];
print “Index for xyz : ” aList. index) ‘xyz’);
print “Index for zara :”, aList. index(‘zara’);
7.Write the output of the given python code :
aList = [123, ‘xyz’, ‘zara’, ‘abc’];
aList.insert (3,2009) print “Final List:”, aList
8.Write the output of the given python code :
aList1 = [123, ‘xyz’, ‘zara’, ‘abc’];
aList.insert (3,2009) print “Final Lista List
9.Write the output of the given python code :
aList1 = [123, ‘xyz’, ‘zara’, ‘abc’];
print “A List:”, aList.pop()
print “B List:”, aList.pop(2)
10. Write the output of the following code
A = [2, 4, 6, 8,10]
L = len (A)
S=o
for I in range (1, L, 2):
S + = A[I]
print “Sum=”, S
11. What is the output of the following?
x = ['ab', 'cd']
for i in x: i.upper()
print(x)
12.What is the output of the following?
x = ['ab', 'cd']
for i in x: x.append(i.upper())
print(x)
13.What is the output of the following?
i= 1
while True:
if i%3 == 0: break
print(i)
i+=1
14.What is the output of the following?
i=5
while True:
if i%0O11 == 0:
break
print(i)
i += 1

You might also like