Tour I
Tour I
REVISION SHEET
>>> a,b=4,2
>>> a+b**2*10
>>> a-b//2**2
>>>a,b,c=1,2,3
>>> a//b**c+a-c*a
11. If a=1,b=2 and c= 3 then which statement will give the output as : 2.0 from the following:
(a) >>>a%b%c+1 (b) >>>a%b%c+1.0
12. Which statement will give the output as : True from the following :
>>>7*(8/(5//2))
>>>import math
>>> math.ceil(1.03)+math.floor(1.03)
>>>import math
>>>math.fabs(-5.03)
(a) 5.0 (b) 5.03 (c) -5.03 (d) None of the above
17.Which of the following are the fundamental building block of a python program.
FLOW OF EXECUTION
(a) if..else statement (b) for statement (c) if-elif statement (d) if statement
22. …………loop is the best choice when the number of iterations are known.
(a) while (b) do-while (c) for (d) None of these
a=5
while a>0:
print(a)
print(“Bye”)
for i in range(1,15,4):
print(i, end=’,’)
26. …………loop is the best when the number of iterations are not known.
27. In the nested loop ……………..loop must be terminated before the outer loop.
for i in range(1,15,5):
print(i,end=’,’)
strlen=len(str1)+5
print(strlen)
35. Which method removes all the leading whitespaces from the left of the string.
36. It returns True if the string contains only whitespace characters, otherwise returns False.
37. It converts uppercase letter to lowercase and vice versa of the given string.
Str.count(‘Hello’,12,25)
Str=”123456”
print(Str.isdigit())
Str=”python 38”
print(Str.isalnum())
Str=”pyThOn”
print(Str.swapcase())
print(Str.rstrip(“rs”))
a) Computer
b) Computers
c) Compute
d) compute
print(Str.isdigit())
a) 21
b) 20
c) 18
d) 19
44.How many times is the word ‘Python’ printed in the following statement.
s = ”I love Python”
for ch in s[3:8]:
print(‘Python’)
a) 11 times
b) 8 times
c) 3 times
d) 5 times
a) str_name[start:end]
b) str_name[start:step]
c) str_name[step:end]
d) str_name[step:start]
A=”Virtual Reality”
print(A.replace(‘Virtual’,’Augmented’))
a) Virtual Augmented
b) Reality Augmented
c) Augmented Virtual
d) Augmented Reality
print(“ComputerScience”.split(“er”,2))
a) [“Computer”,”Science”]
b) [“Comput”,”Science”]
c) [“Comput”,”erScience”]
d) [“Comput”,”er”,”Science”]
48.Following set of commands are executed in shell, what will be the output?
>>>str=”hello”
>>>str[:2]
a) he
b) lo
c) olleh
d) hello
a) index()
b) split()
c) partition()
d) strip()
50.What is the correct python code to display the last four characters of “Digital India”
a) str[-4:]
b) str[4:]
c) str[*str]
d) str[/4:]
LIST:
51. Given the list L=[11,22,33,44,55], write the output of print(L[: :-1]).
a) [1,2,3,4,5]
b) [22,33,44,55]
c) [55,44,33,22,11]
d) Error in code
52. Which of the following can add an element at any index in the list?
a) insert( )
b) append( )
c) extend()
d) all of these
53. Which of the following function will return a list containing all the words of the given
string?
a) split()
b) index()
c) count()
d) list()
i) [1,2,3,4]>[4,5,6]
ii) [1,2,3,4]<[1,5,2,3]
iii) [1,2,3,4]>[1,2,0,3]
iv) [1,2,3,4]<[1,2,3,2]
a) i,ii,iv
b) i,iii,iv
c) i,ii,iii
d) Only iv
55. If l1=[20,30] l2=[20,30] l3=[‘20’,’30’] l4=[20.0,30.0] then which of the following statements will
not return ‘False’:
i) >>>l1==l2
ii) >>>l4>l1
iii) >>>l1>l2
a) ii, iii
b) i,ii,iii
c) i,iii,iv
d) i,iv
56.>>>l1=[10,20,30,40,50]
>>>l2=l1[1:4]
a) [10,30,50]
b) [20,30,40,50]
c) [10,20,30]
d) [20,30,40]
57.>>>l=[‘red’,’blue’]
>>>l = l + ‘yellow’
a) [‘red’,’blue’,’yellow’]
b) [‘red’,’yellow’]
c) [‘red’,’blue’,’yellow’]
d) Error
>>>l=[1,2,3,4]
>>>m=[5,6,7,8]
>>>n=m+l
>>>print(n)
a) [1,2,3,5,6,7,8]
b) [1,2,3,4,5,6,7,8]
c) [1,2,3,4][5,6,7,8]
d) Error
>>>l=[1,2,3,4]
>>>m=l*2
>>>n=m*2
>>>print(n)
a) [1,2,3,4,1,2,3,4,1,2,3,4]
b) [1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4]
c) [1,2,3,4][4,5,6,7]
d) [1,2,3,4]
>>l=list(‘computer’)
Column A Column B
1 L[1:4] a. [‘t’,’e’,’r’]
2 L[3:] b. [‘o’,’m’,’p’]
3 L[-3:] c. [‘c’,’o’,’m’,’p’,’u’,’t’]
4 L[:-2] d. [‘p’,’u’,’t’,’e’,’r’]
a) 1-b,2-d,3-a,4-c
b) 1-c,2-b,3-a,4-d
c) 1-b,2-d,3-c,4-a
d) 1-d,2-a,3-c,4-b
>>>l[4][1]
a) ‘apple’
b) ‘green’
c) ‘red’
d) ‘orange’
62.>>>l[8][0][2]
a) ‘d’
b) ‘e’
c) ‘r’
d) ‘o’
63.>>>l[-1]
a) [‘apple’,’green’]
b) [‘red’,’orange’]
c) [‘red’ ]
d) [’orange’]
64.>>>len(l)
a) 10
b) 9
c) 8
d) 11
>>>l1=[1,2,3]
>>>l1.append([5,6])
>>>l1
a) [1,2,3,5,6]
b) [1,2,3,[5,6]]
c) [[5,6]]
d) [1,2,3,[5,6]]
Show Answer
>>>l1=[1,2,3]
>>>l2=[5,6]
>>>l1.extend(l2)
>>>l1
a) [5,6,1,2,3]
b) [1,2,3,5,6]
c) [1,3,5]
d) [1,2,3,6]
Show Answer
>>>l1=[1,2,3]
>>>l1.insert(2,25)
>>>l1
a) [1,2,3,25]
b) [1,25,2,3]
c) [1,2,25,3]
d) [25,1,2,3,6]
Show Answer
68. >>>l1=[10,20,30,40,50,60,10,20,10]
>>>l1.count(‘10’)
a) 3
b) 0
c) 2
d) 9
Show Answer
a) in
b) not in
c) both (i)&(ii)
Show Answer
70.Which of the following function will return the first occurrence of the specified element in a
list.
a) sort()
b) value()
c) index()
d) sorted()
Show Answer
c) Dictionary is mutable.
d) All of these.
Show Answer
a) List()
b) tuple()
c) TUPLE
d) tup()
Show Answer
a) print(tup[3])
b) tup[2]=55
c) print(max(tup))
d) print(len(tup))
Show Answer
>>>tup1=(1,2,4,3)
>>>tup2=(1,2,3,4)
What will the following statement print(tup1<tup2)
a) True
b) False
c) Error
d) None of these
Show Answer
a) len( )
b) max( )
c) min( )
d) count( )
Show Answer
76. Which function is used to return a value for the given key.
a) len( )
b) get( )
c) keys( )
d) None of these
Show Answer
a) similar
b) unique
d) All of these
Show Answer
a) T=4
b) T=(4)
c) T(4,)
d) T=[4,]
Show Answer
79.Which of the following will delete key-value pair for key=’red’ form a dictionary D1
a) Delete D1(“red”)
b) del. D1(“red”)
c) del D1[“red”]
d) del D1
Show Answer
a) clear( )
b) pop( )
c) delete
d) rem( )
Show Answer