Computerscience Examination Xi Pa-42024-25

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

3. What will be the output of print(list1[1:8:2]) ?

If
list1=[6,23,3,2,0,9,8,75]
4. Suppose a tuple T is declared as T = (10, 12, 43, 39), which of the
PERIODIC ASSESSMENT-4 following is incorrect?
COMPUTER SCIENCE 1. print(T.count(12)) 2. print(any(T))
CLASS: XI 3. print(sum(T)) 4. T.sort()
MAXMARKS :70 TIME:3 HRS 5. Identify the valid declaration of L: L=(“element”,)
a. dictionary b. string c.tuple d. list
General Instructions 6. What will be the output of the following code?
● This question paper contains 37 questions. L = [‘a’,’b’,’c’,’d’] print (“ “.join(L))
● All questions are compulsory. However, internal choices have been (A) Error (B) a b c d (C) [‘a’,’b’,’c’,’d’] (D) None
provided in some 7. If T=(“thistuple”)
questions. Attempt only one of the choices in such questions What will be the output of print(type(T))
● The paper is divided into 5 Sections- A, B, C, D and E. 8. What will be the output of following code-
● Section A consists of 21 questions (1 to 21). Each question carries 1 Mark. list1=[1, 3, 2]
● Section B consists of 7 questions (22 to 28). Each question carries 2 Marks. list1 * 2
● Section C consists of 3 questions (29 to 31). Each question carries 3 Marks. 9. What will be the output of following code-
● Section D consists of 4 questions (32 to 35). Each question carries 4 Marks. print([i.lower() for i in "HELLO"])
● Section E consists of 2 questions (36 to 37). Each question carries 5 Marks. 10. What will be the output of following code-
● All programming questions are to be answered using Python Language a=[[[1,2],[3,4],5],[6,7]] a[0][1][1]
only. 11. What will be the output of following code-
● In case of MCQ, text of the correct answer should also be written. a,b=[3,1,2],[5,4,6]
a+b
Section-A (21 x 1 = 21 Marks) 12. What will be the output of following program: a=[2,1,3,5,2,4]
a.remove(2)
1. State True or False: print(a)
The max() and min() when used with tuples, can work if elements of the 13. State the output t=(1,2,3,4,5) print(t[1:4])
tuple are all of the same types. What is the data type of (1) ?
2. Which of the following statement(s) would give an error during 14. What will be the result of the following
execution of the following code? code?
tup = (20,30,40,50,80,79) a = (1, 2, [3, 4])
print(tup) #Statement 1 a[2][0] = 5
print(tup[3]+50) #Statement 2 print(a)
print(max(tup)) #Statement 3 a. (1, 2, [3, 4]) b. (1, 2, [5, 4])
tup[4]=80 #Statement 4 c. Error: Tuples are immutable
a. Statement 1 b. Statement 2 d. (1, 2, 5, 4)
c. Statement 3 d. Statement 4 15. What will be the output of following Python code?
tp1 = (2,4,3) 21. 21. Assertion (A): Tuple in Python is an ordered and immutable data type.
tp3 = tp1*2 Reasoning (R): Tuples can contain heterogeneous data and permit
print(tp3) duplicate values as well.
a. (4,8,6) b. (2,4,3,2,4,3) c. (2,2,4,4,3,3) d. Error
16. What will be the output of following Python code? SECTION-B(7x2=14)
tp1 = (15,11,17,16,12)
tp1.pop(12) 22. Write the Python statement for each of the following tasks using
print(tp1) BUILT-IN functions/methods only:
a. (15,11,16,12) b. (15,11,17,16) c. (15,11,17,16,12) d.Error (i) To insert an element 200 at the third position,in the list L1.
17. Which of the following options will not result in an error when (ii) To check whether a string named, message ends with a
performed on types in Python where tp = (5,2,7,0,3) ? full stop / period or not.
a. tp[1] = 2 b. tp.append(2) c. tp1=tp+tp d. tp.sum() 23. Find the errors in the following code and write the correct code.
18. What will be the output of the following Python code ? s = [11, 13, 15]
tp = () for n in len(s) :
tp1 = tp * 2 tot = tot + s[n]
print(len(tp1)) print(tot)
a. 0 b. 2 c. 1 d. Error i. Underline the corrections.
19. Given tp = (5,3,1,9,0). Which of the following two statements will ii. Write the reason! error next to it in the comment form.
give the same output? 24. What will be the output of following program:
(i) print( tp[:-1] ) odd = [1, 9]
(ii) print( tp[0:5] ) odd.insert(1,3)
(iii) print( tp[0:4] ) print(odd)
(iv) print( tp[-4:] ) odd[2:2] = [5, 7]
a. (i), (ii) b. (ii), (iv) c. (i), (iv) d. (i), (iii) print(odd)
Directions : In the following questions, A statement of Assertion 25. Predict the output of the following code:
(A) is followed by a statement of odd = [1, 3, 5]
Reason (R). Mark the correct choice as. print(odd + [9, 7, 5])
(A) Both A and R are true and R is the correct explanation for A. print(["re"] * 3)
(B) Both A and R are true and R is not correct explanation for A. 26. What is the output of the following code ?
(C) A is true but R is false. t = (10, 20, 30, 40, 50, 50, 70)
(D) A is false but R is true. print(t[5:-1])
20. 27. Which of the below given functions cannot be used with nested
tuples ? Give the reason.
index( )
count( )
max( )
sum( )
28. If a is (1, 2, 3) Expected output:
what is the difference (if any) between a * 3 and (a, a, a) ? list1 = [5, 10, 15, 200, 25, 50, 20]
Is a * 3 equivalent to a + a + a ? 35. Write a Python program to get the largest number from a list.

SECTION-C(3x3=9) SECTION–E(2x5=10)
36. What will be the output of the following program:
29. What will be the output of following program: l=[10,20,30,40,50,60]
list1 = ["python", "list", 1952, 2323, 432] for i in range(len(l)):
list2 = ["this", "is", "another", "list"] print(list1) if(i%2==0):
1. print(list1[1:4]) print(l[i],end='#')
2. print(list1[1:]) else:
3. print(list1[0]) print(l[i])
30. What will be the output of following program: 37. Write a Program to Find Even elements in a List.
l=[6,12,18,24,30]
for i in l:
for j in range(1,i%5):
print(j,'#',end='')
print().
31. Give the elements of the following tuple which are present at the
given index numbers:
planets=['Mercury', 'Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn', 'Uranus',
'Neptune']
a) planets [2:6:2] b. planets [-5:-1] c.planets [-1:-5:-2]

SECTION-D(4x4=16)

32. Are the following two assignments same ? Why / why not ?
1. T1 = 3, 4, 5
T2 = ( 3, 4 , 5)
2. T3 = (3, 4, 5)
T4 = (( 3, 4, 5))
33. Write a program to input n numbers from the user. Store these
numbers in a tuple. Print the maximum and minimum number from
this tuple.
34. Given a Python list, find value 20 in the list, and if it is present,
replace it with 200. Only update the first occurrence of a value.
list1 = [5, 10, 15, 20, 25, 50, 20]

You might also like