Xi Ip
Xi Ip
Xi Ip
HALF-YEARLY
SUB:-IP DATE:-
STD:-XI SET -D MARKS:-
70
SECTION A
5. Given a list L= [10, 20, 30, 40, 50, 60, 70], what would L[1: 4] return ?
(a) [10, 20, 30, 40] (b) [20, 30, 40, 50] (c) [20, 30, 40] (d) [30, 40, 50]
6. Given a list L= [10, 20, 30, 40, 50, 60, 70], what would L[2 : -2] return?
(a) [10, 20, 30, 40] (b) [20, 30, 40, 50] (c) [20, 30, 40] (d) [30, 40, 50]
7. Given a list L= [10, 20, 30, 40, 50, 60, 70], what would L[-4: -1] return?
(a) [20, 30, 40] (6) [30, 40, 50] (c) [40, 50, 60] (d) [50, 60, 70]
8. Given a list L= [10, 20, 30, 40, 50, 60, 70], what would L[-3: 99] return?
(a) [20, 30, 40] (b) [30, 40, 50] (c) [40, 50, 60] (d) [50, 60, 70]
9. Which of the following commands will create a list?
a) list1 = list() b) list1 = [] c) list1 = list([1, 2, 3]) d) all of the mentioned
10. What is the output when we execute list(“hello”)?
a) [‘h’, ‘e’, ‘l’, ‘l’, ‘o’] b) [‘hello’] c) [‘llo’] d) [‘olleh’]
11. Suppose listExample is [‘h’,’e’,’l’,’l’,’o’], what is len(listExample)?
a) 5 b) 4 c) None d) Error
12. Suppose list1 is [2445,133,12454,123], what is max(list1)?
a) 2445
b) 133
c) 12454
d) 123
13. What is the value of the expression 100 // 25 ?
(a) 4 (6) 4.0 (c) 2.5 (d) none of these
14. In Python, a variable must be declared before it is assigned a value.
(a) True (b) False (c) Only in Functions (d) Only in modules
15. In Python, a variable is assigned a value of one type, and then later assigned a value of a different type. This will
yield
(a) Warning (b) Error (c) None (d) No Error
16.. To add a new element to a list we use which command?
a) list1.add(5) c) list1.addLast(5)
b) list1.append(5) d) list1.addEnd(5)
17. To insert 5 to the third position in list1, we use which command?
a) list1.insert(3, 5) c) list1.add(3, 5)
b) list1.insert(2, 5) d) list1.append(3, 5)
18. To remove string “hello” from list1, we use which command?
a) list1.remove(“hello”) c) list1.removeAll(“hello”)
b) list1.remove(hello) d) list1.removeOne(“hello”)
SECTION B
SECTION C
Q3 Do as dircted: [5 x 3=15M]
1. Write a program to check if a number is present in the list or not. If the number is present, print the position
of the number. Print an appropriate message if the number is not present in the list.
2. Program to read a list and print only those numbrs which are divisible by 5 and not by 7
3. WAP to print following pattern without using any nested loop.
A
BB
CCC
DDDD
SECTION D
SECTION E