What Will Be The Output of The Following Code?: A) 6 B) 8 C) 9 D) 11 B) 8
What Will Be The Output of The Following Code?: A) 6 B) 8 C) 9 D) 11 B) 8
A) .py
B) .python
C) .pt
D) .pyt
Answer: A) .py
print(2 ** 3)
A) 6
B) 8
C) 9
D) 11
Answer: B) 8
Which data structure does Python use to store values as key-value pairs?
A) list
B) set
C) dictionary
D) tuple
Answer: C) dictionary
my_tuple = (1, 2, 3)
print(my_tuple[1])
A) 1
B) 2
C) 3
D) Error
Answer: B) 2
s = "Python"
print(s[1:4])
A) yth
B) Pyt
C) ytho
D) ytho
2
Answer: A) yth
my_list = [1, 2, 3]
my_list.append(4)
print(my_list)
A) [1, 2, 3]
B) [1, 2, 3, 4]
C) [1, 4]
D) [1, 2, 3, 3]
Answer: B) [1, 2, 3, 4]
a) .pyt
b) .pt
c) .py
d) .python
Answer: c) .py
a) func
b) define
c) def
d) lambda
Answer: c) def
a) //
b) <!--
c) #
d) %
Answer: c) #
a) {1, 2, 3}
b) (1, 2, 3)
3
c) [1, 2, 3]
d) <1, 2, 3>
Answer: c) [1, 2, 3]
a) my_var
b) 2var
c) var_2
d) _var
Answer: b) 2var
print("Python" * 2)
a) PythonPython
b) Python2
c) Python Python
d) Error
Answer: a) PythonPython
Which of the following is used to take input from the user in Python?
a) scanf()
b) input()
c) gets()
d) cin
Answer: b) input()
ANSWER: C
ANSWER: A
Which of the following data type is used to store values in Key & Value format?
A. Class
B. List
C. Dictionary
D. Tuple
ANSWER: C
A. +
B. /
C. -
D. ()
ANSWER: D
ANSWER: D
a) loop()
b) while()
c) for()
d) Both b and c
Answer: d) Both b and c
a) import module_name
b) include module_name
c) load module_name
d) use module_name
Answer: a) import module_name
a) lambda
b) pass
c) eval
d) assert
Answer: c) eval
a) =
b) ==
c) !=
d) ===
Answer: b) ==
6
a) Exits the current loop
b) Skips the current iteration
c) Exits the program
d) Stops execution of all loops
Answer: a) Exits the current loop
a) Using keys
b) Using indexes
c) Using values
d) Using positions
Answer: a) Using keys
a) 0
b) None
c) False
d) Error
Answer: b) None
a) [1, 2, 3, 4, 5]
b) [0, 1, 2, 3, 4]
c) (0, 1, 2, 3, 4)
d) None
Answer: b) [0, 1, 2, 3, 4]
a) 3.33
b) 3
c) 4
d) Error
Answer: b) 3
a) List
b) Dictionary
7
c) Tuple
d) Set
Answer: c) Tuple
a) Checks equality
b) Checks identity
c) Checks membership
d) Checks type
Answer: b) Checks identity
a) trim()
b) remove()
c) strip()
d) clear()
Answer: c) strip()
a) try/except
b) throw/catch
c) error/catch
d) raise/handle
Answer: a) try/except
a) list.push(element)
b) list.add(element)
c) list.append(element)
d) list.insert(element)
Answer: c) list.append(element)
print("Hello"[-1])
a) H
b) e
c) o
d) Error
Answer: c) o
a) %
b) .format()
8
c) f-strings
d) All of the above
Answer: d) All of the above
print("Hello".upper())
a) hello
b) HELLO
c) Hello
d) Error
Answer: b) HELLO
a) int()
b) str()
c) float()
d) eval()
Answer: a) int()
a) add()
b) append()
c) insert()
d) update()
Answer: d) update()
a) typeof()
b) dataType()
c) type()
d) varType()
Answer: c) type()
9
A) Labels are unknown
B) Labels are known
C) No training data is available
D) The data is unlabeled
Answer: B) Labels are known
11. Which algorithm would be most suitable for detecting spam emails?
A) K-means clustering
B) Naïve Bayes
C) Linear regression
D) None
Answer: B) Naïve Bayes
A. Test
B. Number
C. Boolean
D. Special
ANSWER: A
A. "This is Python"
B. "P"
C. 'Sum'
D. #Sum#
ANSWER: D
A. Hello World
B. hello World
C. <class 'str'>
D. str
ANSWER: C
A. List
B. Tuple
C. Array
11
D. String
ANSWER: C
A. MYVAR
B. MY%VAR
C. MY_VAR
D. _MY_VAR
ANSWER: B
A. 'ABC'
B. ''ABC''
C. '''ABC'''
D. ''''ABC''''
ANSWER: D
A. "This is Python"
B. [ 10 ,20 , ''ABC'' ]
C. ( 10 ,20 , ''ABC'' )
D. - 10 ,20 , ''ABC'' -
ANSWER: D
12
C. + sign concatenate the list.
ANSWER: B
ANSWER:C
A. **
B. /
C. //
D. ***
ANSWER: D
A. not in
B. not is
C. has
D. none
ANSWER: A
13
A. >>
B. <<
C. >>>
D. ^
ANSWER: C
A. 5
B. 10
C. 15
D. 0
ANSWER: A
A. 5
B. 10
C. 15
D. 20
ANSWER: D
A. if
B. if…else
C. if…else...elif…
D. if…elif…else…
ANSWER: C
14
Which one is not allowed with While Loop?
A. else
B. break
C. continue
D. elif
ANSWER: D
C. It is performs nothing.
ANSWER: D
C. It is performs nothing.
ANSWER: A
A. int
B. float
C. bool
15
D. str
ANSWER: D
A. It is an in-built function.
ANSWER: C
A. else
B. break
C. continue
D. elif
ANSWER: D
C. It is performs nothing.
ANSWER: D
16
B. It repeats the body of the loop.
C. It is performs nothing.
ANSWER: A
A. int
B. list
C. tuple
D. string
ANSWER: A
ANSWER: A
ANSWER: C
17
Which one is true for nested FOR Loop?
ANSWER: B
Which of the following method creates a new array object that looks at the same data?
A. view
B. copy
C. paste
ANSWER: A
A. %f
B. %d
C. %u
D. %t
ANSWER: D
A. Strip( ).
B. Lower( ).
C. Split( ).
D. Repeat( ).
18
ANSWER: D
A. { }
B. [ ]
C. ( )
D. set( )
ANSWER: D
The ________ function returns its argument with a modified shape, whereas the ________ method
modifies the array itself.
A. reshape, resize
B. resize, reshape
C. reshape2, resize
ANSWER: A
A. Structured ndarray
B. Series
C. DataFrame
ANSWER: D
19
A. print(t[3])
B. t[3] = 45
C. print(max(t))
D. print(len(t))
ANSWER: B
B. [2,3]
C. (2,3,4)
D. (2,3)
ANSWER: B
ANSWER: C
ANSWER: D
20
Which one is not true for Dictionary?
A. d1=d2 allows to copy the one dictionary items to other, with reference.
B. d1=d2 allows to copy the one dictionary items to other, without reference.
C. copy( ) method allows to copy the one dictionary items to other, without reference.
D. dict( ) method allows to copy the one dictionary items to other, without reference.
ANSWER: A
A. length()
B. len()
C. strlen()
D. stringlength()
ANSWER: B
A. numpy libraries.
B. pandas libraries.
C. tkinter libraries.
D. matplotlib libraries.
ANSWER: D
A. PCA
B. Decision Tree
21
C. Linear Regression
D. Naive Bayesian
ANSWER: A
ANSWER:D
A. SSE = SST
B. SSE = 1
C. SSR = SSE
D. SSR = SST
ANSWER:D
B. independent variable
C. intervening variable
D. is usually x
ANSWER:A
22
A. The autonomous acquisition of knowledge through the use of computer programs
ANSWER:A
A) Model accuracy
B) The randomness in the data
C) The depth of the tree
D) The number of nodes
Answer: B) The randomness in the data
In a decision tree, which metric is commonly used to split nodes in classification problems?
A) Entropy
B) Gradient
C) Learning Rate
D) Euclidean Distance
Answer: A) Entropy
23