Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
5 views3 pages

Practice Set 2 Python Class XII

The document contains a series of programming questions and tasks divided into sections A through E, covering topics such as Python code evaluation, error handling, and file operations. Each question is assigned a specific mark value and includes multiple-choice answers or requires code completion and function definitions. The questions assess knowledge of Python programming concepts, syntax, and data structures.

Uploaded by

z63021219
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

Practice Set 2 Python Class XII

The document contains a series of programming questions and tasks divided into sections A through E, covering topics such as Python code evaluation, error handling, and file operations. Each question is assigned a specific mark value and includes multiple-choice answers or requires code completion and function definitions. The questions assess knowledge of Python programming concepts, syntax, and data structures.

Uploaded by

z63021219
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Ques Question Marks

No
SECTION A
1 State true or false 1
Interpreter converts a program into machine code as a whole .
2 Predict the output of following code: 1
str=”Jaihind”
print(‘#’.join(str))

(a)J#a#i#h#i#n#d (b)#J#a#i#h#i#n#d#
(c)Jai#hind (d)#jaihind#

3 Evaluate the following expression: 1


5%2+3**2*0
(i) 1 (ii) 4 (iii) 0 (iv) 3
4 What is the output? 1
str=”AdaGroup”
print(str.count(“w”)
(i) 0 (ii) IndexError (iii) ValueError (iv) -1
5 Identify the output of the following code: 1
Str=”SimranThakur”
print(str[-2::-2])
(i) rukahTnarmiS (ii) uaTamS (iii) irnhkr (iv)uatams
6 Which will give the minimum value? 1
t=(2,4,6,8)
(i) min(t) (ii) min.(t) (iii) t.min (iv) none of these
7 State true or false 1
Finally clause never execute whether an exception has occurred
or not.
8 Predict the output of the following code: 1
L=[2,3,4,5]
L.insert(2,6)
print(L)
(i) [2,3,4,5,6]
(ii) [3,4,5,2,6]
(iii) [2,3,6,4,5]
(iv) list is immutable
9 Give the output of the following code: 1
t1= (1,2,3)
t2=t1
t1+=(4,)
print(t1==t2)

10 Complete the missing statement: 1


fo = open (“myfile.txt”, “__”)
fo.write(“pari from 12th “)
fo.close()

11 The lines which are suspected for error are placed in which 1
clause.
(a)except (b)else (c)try (d)finally
12 Identify and correct the error(s) in the following code: 1
def comp(n1,n2):
IF (n1>n2)
return(n2)
else:
return(n1)
s1=comp(5,7)
13 Assertion (A): Python is a high level language. 1
Reason (R) : Python is portable and platform dependent
language.
(i) A is true and R is the correct explanation of A.
(ii) A is true and R is not the correct explanation of A.
(iii) A is true and R is false
(iv) A is false and R is true

SECTION B

14 Which of the following code will cause an error? Also state the 2
reason.
L=[10,20,30,40] t=(10,20,30,40)
L.insert(2,40) t.insert(2,40)
print (L) print(t)
15 Which of the following has the higher priority and explain the 2
function of the following operators.
% , **
16 Write data in L1 and L2 after the operations: 2
L1=[15,8,9,91] L2=[3,4,9,8]
(i) L1.remove(91) (ii) L2.reverse()
17 Define any two functions of random module with example of 2
each.

SECTION C

18 Write a function that finds the total number of words present in 3


the file named “adagroup.txt”.

19 Convert the expression 9**225/7+9*8 into postfix expression 3


using stack while displaying the stack at each step.

SECTION D
20 (i) Define IndentationError? 1+3
(ii) Give one example code to handle the IndentationError.
21 Consider a file named “student.csv” with the following columns. 4
sid =student’s id, sName=student name, sNo.=student’s mobile
number
(i) Write a function to display the name of a student whose id is
21
(ii) Write a function to add a record of following student:
101,Anisha,9596XXXXX

SECTION E
22 Consider a binary file to store record of different type of place 5
with the attributes:
Place, population, famous food
(i) Write a function which writes the record of 2 places in this file.
(ii) Write a function which displays the famous food of a given
place.

You might also like