ACHARYA MAHASHRAMAN TERAPANTH JAIN PUBLIC SCHOOL
COMPUTER SCIENCE -083
WORKSHEET-1
PYTHON REVISION TOUR
Q.NO. QUESTIONS
1. Which of the following is not considered a valid identifier in Python ?
(i) Two2 (ii) _main (iii) hello_rsp1 (iv) 2 hundred
2. What will be the output of the following code ?
print(“100+200”)
(i) 300 (ii) 100200 (iii) 100+200 (iv) 200
3. pow( ) function belongs to which library ?
(i) math (ii) string (iii) random (iv) maths
4. What is the output of the following ?
x = 123
for i in x:
print(i)
(i) 123 (ii) 1 2 3 (iii) error (iv) infinite
5. What data type is the object below?
L = 1, 23, ‘hello’,1
( a) list (b) dictionary (c) array (d) tuple
6. What is the value of this expression 3**3**1 ?
(i) 27 (ii) 9 (iii) 3 (iv) 1
7. List AL is defined as follows:
AL=[1,2,3,4,5]
Which of the following statement/statements removes the middle element 3 from it so that the
list AL equals [1,2,4,5] ?
( a) del a[2] (b) a[2:3] = [ ] (c) a[2 : 2]=[ ]
(d) a[ 2 ] = [ ] (e) a.remove(3)
8. Find the valid identifier from the following
a) False b) Ist&2nd c) 2ndName d) My_Name
9. Given the lists L=[1,30,67,86,23,15,37,131,9232] , write the output of print(L[3:7])
( a) [67,86,23,15,37] (b) [86,23,15,37]
10. Identify the invalid logical operator in Python from the following.
a) and b) or c) not d) Boolean
11. Suppose a tuple T is declared as T = (10, 12, 43, 39), which of the following is Incorrect?
a) print( T[1] ) b) print(max(T))
c) print(len(T)) d) None of the these
12. A list is declared as
Lst = [1,2,3,4,5,6,8]
What will be the value of sum(Lst)?
(i) 29 (ii) 30 (iii) 7 (iv) 8
13. If the following code is executed, what will be the output of the following
code?
name="Computer_Science_with_Python"
print(name[-25:10])
(i) puter_S (ii) hon (iii) puter_Science
14. Can tuple be nested?
(a) Yes (b) No
15. Can we modify/change keys of a dictionary ?
(a) Yes (b) No
16. ………………method of list is used to delete a given element from the list.
(i) del (ii) extend( ) (iii) remove( ) (iv) append( )
17. A tuple is declared as
T = (2,66,77,55,6,9,55,8)
Write the output of
print(T.index(55))
(i) 4 (ii) 3 (iii) 55 (iv) None of these.
18. Which of the following is/are valid declaration of a dictionary?
a) D = {'StuName': 'Alan', 'StuAge': 30, 'StuCity': 'Vizag'}
b) D = ['StuName': 'Alan', 'StuAge': 30, 'StuCity': 'Vizag']
c) D = ('StuName': 'Alan', 'StuAge': 30, 'StuCity': 'Vizag')
d) D = {'StuName'; 'Alan', 'StuAge': 30, 'StuCity': 'Vizag'}
19. If the following code is executed, what will be the output of the following code?
Title="Online Teaching 2020"
print(Title[6:10], Title[-2:-4:-1])
(a) Tea 20 (b) Error (c) e Tea 02
20. Write the output of the following python expression:
print((4>5) and (2!=1) or (4<9))
(i) False (ii) True
21. Find the operator which cannot be used with a string in Python from the following:
(a) + (b) in (c) * (d) //
22. Which of the following is not a keyword?
(a) eval
(b) assert
(c) nonlocal
(d) pass
23. Which value type does input() return?
(a) Boolean
(b) String
(c) Int
(d) Float
24. The operator tells if an element is present in a sequence or not.
(a) exists
(b) in
(c) into
(d) inside
25. The keys of a dictionary must be of types.
(a) Integer
(b) mutable
(c) immutable
(d) any of these
26 What is the output when we execute list(“hello”)?
a) [‘h’, ‘e’, ‘l’, ‘l’, ‘o’]
b) [‘hello’]
c) [‘llo’]
d) [‘olleh’]
27 Suppose list1 is [2445,133,12454,123], what is max(list1)?
a) 2445
b) 133
c) 12454
d) 123
28 Suppose list1 is [2, 33, 222, 14, 25], What is list1[-1]?
a) Error
b) None
c) 25
d) 2
29 Suppose list1 is [2, 33, 222, 14, 25], What is list1[:-1]?
a) [2, 33, 222, 14]
b) Error
c) 25
d) [25, 14, 222, 33, 2]
30 To add a new element to a list we use which command?
a) list1.add(5)
b) list1.append(5)
c) list1.addLast(5)
d) list1.addEnd(5)
31 To insert 5 to the third position in list1, we use which command?
a) list1.insert(3, 5)
b) list1.insert(2, 5)
c) list1.add(3, 5)
d) list1.append(3, 5)
32 Suppose list1 is [3, 4, 5, 20, 5], what is list1.index(5)?
a) 0
b) 1
c) 4
d) 2
Suppose list1 is [3, 4, 5, 20, 5, 25, 1, 3], what is list1.count(5)?
a) 0 b) 4
c) 1 d) 2
33 Suppose listExample is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after listExample.extend ([34, 5])?
a) [3, 4, 5, 20, 5, 25, 1, 3, 34, 5]
b) [1, 3, 3, 4, 5, 5, 20, 25, 34, 5]
c) [25, 20, 5, 5, 4, 3, 3, 1, 34, 5]
d) [1, 3, 4, 5, 20, 5, 25, 3, 34, 5]
34 Suppose listEx is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after listEx.pop() ?
a) [3, 4, 5, 20, 5, 25, 1]
b) [1, 3, 3, 4, 5, 5, 20, 25]
c) [3, 5, 20, 5, 25, 1, 3]
d) [1, 3, 4, 5, 20, 5, 25]
35 Suppose d = {“john”:40, “peter”:45}, to delete the entry for “john” what command do we use?
a) d.delete(“john”:40)
b) d.delete(“john”)
c) del d[“john”]
d) del d(“john”:40)
36 Which of the following is not a declaration of the dictionary?
a) {1: ‘A’, 2: ‘B’}
b) dict([[1,”A”],[2,”B”]])
c) {1,”A”,2”B”}
d) { }
37 Which of the following isn’t true about dictionary keys?
a) More than one key isn’t allowed
b) Keys must be immutable
c) Keys must be integers
d) When duplicate keys encountered, the last assignment wins
38 What will be the output of the following Python code?
a={}
a[2]=1
a[1]=[2,3,4]
print(a[1][1])
a) [2,3,4]
b) 3
c) 2
d) An exception is thrown
39 Which of the following statement prints hello\example\test.txt?
a) print(“hello\example\test.txt”)
b) print(“hello\\example\\test.txt”)
c) print(“hello\”example\”test.txt”)
d) print(“hello”\example”\test.txt”)
40 What will be the output of the “hello” +1+2+3?
a) hello123
b) hello
c) Error
d) hello6
41 Say s=”hello” what will be the return value of type(s)?
a) int
b) bool
c) str
d) String
42 What is “Hello”.replace(“l”, “e”)?
a) Heeeo
b) Heelo
c) Heleo
d) None
43 What will be the output of the following Python code?
Given a string example=”hello” what is the output of example.count(‘l’)?
a) 2
b) 1
c) None
d) 0
44 What will be displayed by print(ord(‘b’) – ord(‘a’))?
a) 0 b) 1
c) -1 d) 2
45 What will be the output of the following Python code?
print(“abc DEF”.capitalize())
a) abc def
b) ABC DEF
c) Abc def
d) Abc Def
46 What will be the output of the following Python code?
print(‘a B’.isalpha())
a) True b) False c) None d) Error
47 What will be the output of the following Python code snippet?
print(‘my_string’.isidentifier())
a) True b) False c) None d) Error
48 What will be the output of the following Python code?
print(‘xyxxyyzxxy.lstrip(‘xyy’))
a) zxxy b) xyxxyyzxxy c) xyxzxxy d) none of the mentioned
49 What will be the output of the following Python code snippet?
print(‘abcdef12’.replace(‘cd’,’12’))
a) ab12ef12
b) abcdef12
c) ab12efcd
d) none of the mentioned
50 What will be the output of the following Python code?
list1 = [1,2,3,4]
list2 = [5,6,7,8,]
print(len(list1+list2))
a) 2
b) 4
c) 5
d) 8