XI AnnualExam CS
XI AnnualExam CS
Page 1 of 6
Which of the following statement(s) would Find the output for the given
give an error after executing the following statement .
code? print((not True ) or False and True)
str= “Python Programming” #statement 1
13 x= ‘2’ #statement 2 14 a) True b) False c) None d) Null
print(str*2) #statement 3
print(str*x) #statement 4
a) statement 1 b) statement 2
c) statement 3 d) statement 4
Find the output for the given statement. Which of the following is not a
T=(10,20,30,40,50,60) dictionary object function?
del T[2:5] a) pop() b) clear() c)min() d) index()
15 16
print(T)
a) (10,20,60) b) (10,20,30) c) (10,20)
d) Type Error
Which of the following is not a valid import random as r
statement in Python? Value=x.randint(10,20)-2
a) x=10,20 b) x,y=10,20 In the above code segment identify
17 c) x,y=10,20,30 d) x=y=10 18 the minimum and maximum value
that can be assigned to the identifier
Value .
a) 10,20 b) 8,18 c) 10,18 d) 8,20
SECTION B
Aruna has written a code to find the sum of even and odd elements from first 10 natural
numbers. Her code is having errors. Rewrite the correct code and underline the
corrections made.
sume=0
0 =sumo
for i in range of 1,11:
19
if i%2=0:
sume+=i
Else
sumo+=i
print(“The sum of even numbers is:”, sume)
print(“The sum of odd numbers is:”, sumo)
Predict the output of the Python code Differentiate between pop() and
given below: popitem() functions in dictionary with
tuple1 = (10,20,30,40,50,60) suitable examples.
list1 =list(tuple1)
new_list = [] OR
20 for i in list1: 21 Differentiate between count() and
if i%3==0: index() function in list with suitable
new_list.append(i) examples .
new_tuple = tuple(new_list)
print(new_tuple)
Page 2 of 6
Raj,created a Python program using list. a) Find the output for the code
Some parts of the code are missing . segment.
Help him to find the suitable code. x,y,z=1,2,3
Lst=[100,200,300,400,500,600] x*=y
______ # Statement 1 z+=y
22 print(Lst) 23 y-=x
_____ # Statement 2 print(x,y,z,sep='$')
print(Lst)
a) Statement 1 – delete the elements b) Evaluate 24//6-3*2**2
300,400 from the list Lst
b) Add the element 700 to the list Lst
Find the output for the code segment. Find the output t for the code
Str='computer' segment.
Str=Str*2 stud={'A':120,'B':170,'C':240}
24 25
print(Str[::-4],end='#') stud.update({'A':150,'D':300,'C':200})
print(Str[2:10:3]) print(stud)
print(Str.index('o',2))
Find the output for the code segment. Explain any two type of errors in
data = [2,4,2,1,2,1,3,3,4,4] Python with suitable examples .
d = {} OR
for x in data: Differentiate between pop() and
if x in d: remove() functions in List object .
d[x]=d[x]+1
else:
26 27
d[x]=1
print(d)
OR
T='they play we play Lets play'
A=T.partition('play')
B=T.split('play')
print(A,'$',B)
What possible outputs(s) are expected to be displayed on screen at the time of
execution of the program from the following code? Also specify the maximum values
that can be assigned to each of the variables FROM and TO.
import random
AR=[20,30,40,50,60,70]
28
FROM=random.randint(1,3)
TO=random.randint(2,4)
for K in range(FROM,TO):
print (AR[K],end=”#“)
(i)10#40#70# (ii)30#40#50# (iii)50#60#70# (iv)40#50#70#
Find the output for the code segment.
a) print("This is","My Python",sep='$',end='*')
print()
29
print("This is My Python",sep='*',end='$')
b) import math
print(math.ceil(63.36),'@',math.floor(-27.72))
Page 3 of 6
SECTION C
a) Find the output for the following code segment.
p,q,r=10,17,23
a,b,c=4,3,7
r,p,q=c//4,b**2,a*2
print(p,q,r,sep='$')
b,a,c=a*p,b//r,c*q
print(a,b,c,sep='#')
b) Find the output for the following code segment.
30
p=32//6
q=p%4
r=p+q
print(p,q,r,sep='&')
p+=p+q-r
r*=p-q+r
q+=p+q
print(p,q,r,sep='*')
Find the output for the following code segment.
T='GoODByE@22'
M=''
for i in range(len(T)):
if T[i].isupper():
M=M+T[i-1]
elif T[i].islower():
M=M+T[i].upper()
elif T[i].isdigit():
M=M+'*'
else:
M=M+'#'
print('The Encrypted text is ' , M)
OR
31 old="THiNk@23"
L=len(old)
new=""
for i in range(0,L):
if old[i].isupper():
new+=old[i+1]
elif old[i].islower():
new+=old[i].upper()
elif old[i].isdigit():
new+=str(old[i])
else:
new+='%'
print("The new text is ",new)
Page 4 of 6
Find the output for the following code segment.
L=[13,15,26,7,9,27,11]
for i in range(len(L)):
if L[i]%2==0:
L[i]*=2
elif L[i]%3==0:
L[i]*=3
elif L[i]%4==0:
L[i]+=4
else:
L[i]*=3
32 print("Updated List is ", L)
OR
A=[7,3,4,5,6,1,2,3,7,3]
print(A[A[A[5]]])
A.insert(5,3)
A.pop(-2)
print(A)
print(A[A[A[5]]])
print(A[-2:2:-2])
print(sorted(A,reverse=False))
del A[3:len(A)-2]
print(A)
Find the output for the following code segment.
L=[4,8,10,12,14,16,18]
T1=tuple(L[::2])
print("The First Tuple is",T1)
33
T2=T1+tuple(L[::-3])
print("The Second Tuple is",T2)
print("Sum of Tuple 1=",sum(T1))
print("Sorting in Tuple 2 = ",sorted(T2))
Find the output for the following code segment.
OR
34 m
Page 5 of 6
SECTION D
Write a program in Python to input a sentence from user and display all the words start
with upper case letter and its count .
For example if the inputted text is This is My Python example
The Expected Output is
Words start with Uppercase are This My Python
Count = 3
35 OR
Write a program is Python to input a text from user and display how many times the
letters ‘a’ and ‘e’ is present in the text .
For example if the inputted text is My name is Meena
The Expected Output is
Total count of letter a is 2
Total count of letter e is 3
Consider a list A= [7,-8,12,36,-45,36,-99,12] . Create two more list name B and C
where B is used to store index location of positive numbers and C is used to store index
location of negative numbers. Print lists B and C .
The Expected Output is
List B is [0,2,3,5,7]
List C is [1,4,6]
36 OR
Consider a list Num=[23,15,21,36,42,55,88] . Create two more list Num1 and Num2
Used to store numbers divisible by 7 and 5 respectively .Print the lists Num1 and
Num2 .
The Expected Output is
List Num1 is [21,42]
List Num2 is [15,55]
Consider a string S = ‘hardware’ , create a dictionary letter used to store all the letters
in the string as the key and the total number of occurrence as the value . Display the
dictionary letter.
The Expected output is
37 The dictionary is {'h':1,'a':2,'r':2,'d':1,'w':1,'e':1}
OR
Create a dictionary Vehicle , where vehicle type as the key and their price as the
value.Input 5 records in to the dictionary and display all the vehicle type those price
above 10 Lakhs from the dictionary Vehicle .
*********************************************************************
Page 6 of 6