0% found this document useful (0 votes)
15 views14 pages

Tour I

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views14 pages

Tour I

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

TOUR I & II

REVISION SHEET

1. Which of the following is a valid identifier:

(a) 9type (b) _type (c) Same-type (d) True

2. Which of the following is a relational operator:

(a) > (b) // (c) or (d) *

3. Which of the following is a logical operator:

(a) + (b) /= (c) and (d) in

4. Identify the membership operator from the following:

(a) in (b) not in (c) both i & ii

5. Which one is a arithmetic operator:

(a) not (b) * (c) both i & ii (d) Only ii

6. What will be the correct output of the statement : >>>4//3.0

(a) 1 (b) 1.0 (c) 1.3333 (d) None of the above

7. What will be the correct output of the statement : >>> 4+2**2*10

(a) 18 (b) 80 (c) 44 (d) none of the answer

8. Give the output of the following code:

>>> a,b=4,2

>>> a+b**2*10

(a) 44 (b) 48 (c) 40 (d) 88

9. Give the output of the following code:

>>> a,b = 4,2.5

>>> a-b//2**2

(a) 4.0 (b) 4 (c) 0 (d) None of the above

10. Give the output of the following code:

>>>a,b,c=1,2,3

>>> a//b**c+a-c*a

(a) -2 (b) -2.0 (c) 2.0 (d) None of the above

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

(c) >>>a%b%c (d) a%b%c-1

12. Which statement will give the output as : True from the following :

(a) >>>not -5 (b) >>>not 5 (c) >>>not 0 (d) >>>not(5-1)

13. Give the output of the following code:

>>>7*(8/(5//2))

(a) 28 (b) 28.0 (c) 20 (d) 60

14. Give the output of the following code:

>>>import math

>>> math.ceil(1.03)+math.floor(1.03)

(a) 3 (b) -3.0 (c) 3.0 (d) None of the above

15.What will be the output of the following code:

>>>import math

>>>math.fabs(-5.03)

(a) 5.0 (b) 5.03 (c) -5.03 (d) None of the above

16.Single line comments in python begin with……………….. symbol.

(a) # (b) “ (c) % (d) _

17.Which of the following are the fundamental building block of a python program.

(a) Identifier (b) Constant (c) Punctuators (d) Tokens

18.The input() function always returns a value of ……………..type.

(a) Integer (b) float (c) string (d) Complex

19.……….. function is used to determine the data type of a variable.

(a) type( ) (b) id( ) (c) print( ) (d) str( )

20.The smallest individual unit in a program is known as a……………

(a) Token (b) keyword (c) punctuator (d) identifier

FLOW OF EXECUTION

#Decision making statements in python Statement

21. Which of the following is not a decision making statement

(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

23. How many times will the following code be executed.

a=5

while a>0:

print(a)

print(“Bye”)

(a) 5 times (b) Once (c) Infinite (d) None of these

24. What abandons the current iteration of the loop

(a) continue (b) stop (c) infinite (d) Break

25. Find the output of the following python program

for i in range(1,15,4):

print(i, end=’,’)

(a) 1,20,3 (b) 2,3,4 (c) 1,5,10,14 (d) 1,5,9,13

26. …………loop is the best when the number of iterations are not known.

(a) while (b) do-while (c) for (d) None of these

27. In the nested loop ……………..loop must be terminated before the outer loop.

(a) Outer (b) enclosing (c) inner (d) None of these

28. …………..statement is an empty statement in python.

(a) pass (b) break (c) continue (d) if

29. How many times will the following code be executed

for i in range(1,15,5):

print(i,end=’,’)

(a) 3 (b) 4 (c) 1 (d) infinite

30. Symbol used to end the if statement:

(a) Semicolon(;) (b) Hyphen(-) (c) Underscore( _ ) (d) colon(:)

String Methods and Built-in functions:

31. Which of the following is not a python legal string operation.

(a) ‘abc’+’aba’ (b) ‘abc’*3 (c) ‘abc’+3 (d) ‘abc’.lower()

32. Which of the following is not a valid string operation.

(a) Slicing (b) concatenation (c) Repetition (d) floor


33. Which of the following is a mutable type.

(a) string (b) tuple (c) int (d) list

34. What will be the output of the following code

str1=”I love Python”

strlen=len(str1)+5

print(strlen)

(a) 18 (b) 19 (c) 13 (d) 15

35. Which method removes all the leading whitespaces from the left of the string.

(a) split() (b) remove() (c) lstrip() (d) rstrip()

36. It returns True if the string contains only whitespace characters, otherwise returns False.

(a) isspace() (b) strip() (c) islower() (d) isupper()

37. It converts uppercase letter to lowercase and vice versa of the given string.

(a) lstrip() (b) swapcase() (c) istitle() (d) count()

38.What will be the output of the following code.

Str=’Hello World! Hello Hello’

Str.count(‘Hello’,12,25)

(a) 2 (b) 3 (c) 4 (d) 5

39.What will be the output of the following code.

Str=”123456”

print(Str.isdigit())

(a) True (b) False (c) None (d) Error

40.What will be the output of the following code.

Str=”python 38”

print(Str.isalnum())

(a) True (b) False (c) None (d) Error

41.What will be the output of the following code.

Str=”pyThOn”

print(Str.swapcase())

(a) PYtHoN (b) python (c) python (d) PYTHON

42.What will be the output of the following code.


Str=”Computers”

print(Str.rstrip(“rs”))

a) Computer

b) Computers

c) Compute

d) compute

43.What will be the output of the following code.

Str=”This is Meera\’ pen”

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

45.Which of the following is the correct syntax of string slicing:

a) str_name[start:end]

b) str_name[start:step]

c) str_name[step:end]

d) str_name[step:start]

46.What will be the output of the following code?

A=”Virtual Reality”

print(A.replace(‘Virtual’,’Augmented’))
a) Virtual Augmented

b) Reality Augmented

c) Augmented Virtual

d) Augmented Reality

47.What will be the output of the following code?

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

49.………..function will always return tuple of 3 elements.

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()

54.Which of the following statements are True.

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

iv) >>> l2==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]

What will be the elements of list l2:

a) [10,30,50]

b) [20,30,40,50]

c) [10,20,30]

d) [20,30,40]

57.>>>l=[‘red’,’blue’]

>>>l = l + ‘yellow’

What will be the elements of list l:

a) [‘red’,’blue’,’yellow’]

b) [‘red’,’yellow’]

c) [‘red’,’blue’,’yellow’]

d) Error

58.What will be the output of the following code:

>>>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

59.What will be the output of the following code:

>>>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]

60.Match the columns: if

>>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

61. If a list is created as

>>>l=[1,2,3,’a’,[‘apple’,’green’],5,6,7,[‘red’,’orange’]] then what will be the output of the following


statements:

>>>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

65.What will be the output of the following code:

>>>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

66.What will be the output of the following code:

>>>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

67. What will be the output of the following code:

>>>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

69.Which operators can be used with list?

a) in

b) not in

c) both (i)&(ii)

d) Arithmetic operator only

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

MCQ Tuples and Dictionary:

71. Which of the statement(s) is/are correct.

a) Python dictionary is an ordered collection of items.

b) Python dictionary is a mapping of unique keys to values

c) Dictionary is mutable.

d) All of these.

Show Answer

72. ………function is used to convert a sequence data type into tuple.

a) List()

b) tuple()

c) TUPLE

d) tup()

Show Answer

73. It tup=(20,30,40,50), which of the following is incorrect

a) print(tup[3])

b) tup[2]=55

c) print(max(tup))

d) print(len(tup))

Show Answer

74. Consider two tuples given below:

>>>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

75. Which function returns the number of elements in the tuple

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

77.Keys of the dictionary must be

a) similar

b) unique

c) can be similar or unique

d) All of these

Show Answer

78. Which of the following is correct to insert a single element in a tuple .

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

80.Which function is used to remove all items form a particular dictionary.

a) clear( )

b) pop( )

c) delete

d) rem( )

Show Answer

You might also like