![]()
1. ________ is the created Python and released in 1991.
a) Dennis Ritchie
b) James Gosling
c) Guido van Russom
d) Bjarne Stroustrup
Option C – Guido van Russom
2. Which of the following is the right syntax for ‘print’ function in Python?
a) printf(“Hello World”);
b) print(“Hello World”)
c) print(“Hello World”);
d) Console.WriteLine(“Hello World”);
Option b- print(“Hello World”)
option c) is wrong as it is ending with a semicolon
3. What is the greatest advantage of Python programming language, from the following?
a) It has a simpler syntax and hence its beginner friendly language.
b) It can be used as procedural way, functional way or even object oriented way.
c) It can also be used for system scripting.
d) All of the above
Ans: d) All of the above
Option b- print(“Hello World”)
4. Statement 1: Indentation in Python is only to enhance readability and understanding of the code.
Statement 2: Indentation in Python is very important as it indicates a block of code.
a) Statement 1 is true and Statement 2 is false
b) Statement 1 is false and Statement 2 is true
c) Both Statement 1 and Statement 2 are false
d) None of the above options are correct
Ans: b) Statement 1 is false and Statement 2 is true
Option b- print(“Hello World”)
5. The correct syntax of comment line in Python is:
a) #This is a comment
b) //This is a comment
c) /* This is a comment */
d) – This is a comment
Ans: a) #This is a comment
Option b- print(“Hello World”)
CHAPTER 2: VARIABLES
6. Variable declaration in Python is:
a) int x;
b) int x=5;
c) $x = 5;
d) x = 5
Ans: d) x = 5, there is no variable declaration syntax in Python, variable is created when a value is assigned to it.
Option b- print(“Hello World”)
7. Guess the output of the following code:
Y = 12
Y = “ABC”
print(Y)
a) ABC
b) 12
c) Error message is displayed
d) None of the above
Ans: a) ABC is the output displayed
Option b- print(“Hello World”)
8. Guess the output of the following code:
x = “smart”
print(x)
x = ‘smart’
print(x)
a) smart
smart
b) smart
Error message
c) Error message
smart
d) smart
Garbage value
Ans: a) smart
smart ,String variables can be declared either in single quotes or double quotes
Option b- print(“Hello World”)
9. Mention ‘legal’ and ‘illegal’ for the variable names respectively:
var1, Var1, 1var, var_1, VAR1, var@1, var-1, -var1, _vaR1
a) legal, illegal, illegal, legal, illegal, legal, legal, illegal, legal
b) illegal, legal, illegal, legal, illegal, legal, illegal, legal, illegal
c) legal, legal, illegal, legal, legal, illegal, illegal, illegal, legal
d) illegal, illegal, legal, illegal, illegal, legal, legal, legal, illegal
Ans: c) legal, legal, illegal, legal, legal, illegal, illegal, illegal, legal
Option b- print(“Hello World”)
10. Mention cases for multi words variable names- camel case, pascal case, snake case respectively:
first_variable_name, FirstVariableName, firstVariableName
a) camel case, pascal case, snake case
b) pascal case, camel case, snake case
c) snake case, pascal case, camel case
d) snake case, camel case, pascal case
Ans: c) snake case, pascal case, camel case
Option b- print(“Hello World”)
11. Camel case for multi words variable names is defined as:
a) Each word, except the first, starts with a capital letter; firstVariableName
b) Each word starts with a capital letter; FirstVariableName
c) Each word is separated by an underscore character; first_variable_name
d) None of the above
Ans: a) Each word, except the first, starts with a capital letter; firstVariableName
Option b- print(“Hello World”)
12. Pascal case for multi words variable names is defined as:
a) Each word, except the first, starts with a capital letter; firstVariableName
b) Each word starts with a capital letter; FirstVariableName
c) Each word is separated by an underscore character; first_variable_name
d) None of the above
Ans: b) Each word starts with a capital letter; FirstVariableName
Option b- print(“Hello World”)
13. Snake case for multi words variable names is defined as:
a) Each word, except the first, starts with a capital letter; firstVariableName
b) Each word starts with a capital letter; FirstVariableName
c) Each word is separated by an underscore character; first_variable_name
d) None of the above
Ans: c) Each word is separated by an underscore character; first_variable_name
Option b- print(“Hello World”)
14. Guess the output of the following code:
m, n, p = “pen”, “pencil”, “eraser”
print(m)
print(n)
print(p)
a) pen
pencil
eraser
b) pen
pen
pen
c) eraser
eraser
eraser
d) Displays an error message
Ans: a) pen
pencil
eraser , this is the example of syntax of assigning many values to multiple variables
Option b- print(“Hello World”)
15. Guess the output of the following code:
x = y = z = “Laptop”
print(x)
print(y)
print(z)
a) Error message
b) Laptop
Laptop
Laptop
c) Laptop
Laptop
Error message
d) None of the above
Ans: b) Laptop
Laptop
Laptop , this is an example of assigning one value to multiple variables
Option b- print(“Hello World”)
16. What is unpacking in Python?
a) Creating a repository containing the revisions from other repository
b) Extraction of value, from a collection of values in a list, tuple etc., into variables
c) Copy revisions from one repository into another
d) All of the above
Ans: b) Extraction of value, from a collection of values in a list, tuple etc., into variables
Option b- print(“Hello World”)
17. Guess the output of the following code:
vegetables = [“peas”, “carrots”, “beans”]
x = y = z = vegetables
print(x)
print(y)
print(z)
a) peas
peas
peas
b) carrots
carrots
carrots
c) beans
beans
beans
d) peas
carrots
beans
Ans: d) peas
carrots
beans , This is example of the concept unpacking.
Option b- print(“Hello World”)
18. Guess the output of the following code:
x = “we ”
y = “love ”
z = “coding”
print( x, y, z)
print( x + y + z)
a) we, love, coding
we + love + coding
b) we + love + coding
we + love + coding
c) we love coding
we love coding
d) welovecoding
welovecoding
Ans: c) we love coding
we love coding, as space character is there after “we ” and “love ”
Option b- print(“Hello World”)
19. Guess the output of the following code:
x = 500
y = “Python”
print(x + y)
print(x, y)
a) Error message
Error message
b) 500 + Python
500, Python
c) 500 Python
500 Python
d) Error message
500 Python
Ans: d) Error message
500 Python
The first output is type error and unsupported operand types as first variable is ‘int’ and second variable is ‘str. The advisable way to output multiple variables in print() is to separate using commas.
Option b- print(“Hello World”)
20. Global variables are defined as:
a) Variables declared outside the function
b) Variables declared inside the function
c) Variables declared inside the function with ‘global’ keyword
d) Both a) and c)
Ans: d) Both a) and c)
Option b- print(“Hello World”)
21. Guess the output of the following code:
x = “Hello”
def func():
global x
x = “World”
func()
print(“Python” + x)
a) Python Hello
b) Python World
c) Error message: TypeError unsupported operand types
d) None of the above
Ans: b) Python World
Option b- print(“Hello World”)
CHAPTER 3: DATA TYPES
22. ‘lists, tuple and range’ comes in which data type in Python
a) Mapping type
b) Set type
c) Sequence type
d) Numeric type
Ans: c) Sequence type
Option b- print(“Hello World”)
23. ‘bytes, bytearray, memoryview’ comes in which data type in Python
a) Binary type
b) Boolean type
c) None type
d) Sequence type
Ans: a) Binary type
Option b- print(“Hello World”)
24. Guess the output of the following code:
import random
print(random.randrange(1, 10))
a) 1
b) 8
c) 3
d) All of the above
Ans: d) All of the above, outputs come in the range of 1 to 10 including 1 and 10
Option b- print(“Hello World”)
25. Guess the output of the following code:
a = ‘‘‘Today
is a
good day’’’
print(a)
a) Today is a good day
b) Todayisagoodday
c) Today
is a
good day
d) None of the above
Ans: c) Today
is a
good day
as the strings in single quotes also include line breaks as the same position in code
Option b- print(“Hello World”)
26. Guess the output of the following code:
for x in “banana”:
print(x)
print(5)
a) b
5
a
5
n
5
a
5
n
5
a
5
b) b
a
n
a
n
a
5
5
5
5
5
5
c) banana 5
d) banana555555
Ans: a) b
5
a
5
n
5
a
5
n
5
a
5 , example of looping through a string
Option b- print(“Hello World”)
27. _________ is the keyword used to check if a certain phrase or character is not present in a string.
a) if
b) if else
c) not in
d) if not
Ans: c) not in
Option b- print(“Hello World”)
28. We can return a part of string by specifying the start index and end index separated by colon, and this technique in Python is called:
a) Concatenate strings
b) Slicing strings
c) Modify strings
d) Format strings
Ans: b) Slicing strings
Option b- print(“Hello World”)
29. Guess the output of the following code:
a = “ Hello, World! ”
print(a.strip())
a) Hello,World
b) Hello,World!
c) HelloWorld
d) Hello, World!
Ans: d) Hello, World! , The strip() method removes white space from beginning or the end
Option b- print(“Hello World”)
30. Method that takes passed arguments, formats them and places them in the string where the placeholders {} are is:
a) format()
b) extend()
c) append()
d) insert()
Ans: a) format()
Option b- print(“Hello World”)
31. _________ is used to insert characters that are illegal in the string.
a) Format specifier
b) modify()
c) Escape character
d) insert()
Ans: c) Escape character
Option b- print(“Hello World”)
32. ___________ is used to convert string into lower case
a) casefold()
b) lower()
c) islower()
d) both a) and b)
Ans: d) both a) and b)
Option b- print(“Hello World”)
33. Guess the output of the following code:
print(bool(“Python”))
print(bool(0))
print(bool())
print(bool(456))
print(bool([“yes”, “no”, “ ”]))
print(bool(None))
a) True
False
True
False
True
False
b) True
True
True
False
False
False
c) True
False
False
True
True
False
d) Python
0
False
True
yes no
False
Ans: c) True
False
False
True
True
False
Boolean data type only gives 2 values: ‘true’ and ‘false’, it gives ‘false’ in the cases of empty set, ‘0’, none, and in the set if there is an empty space with other value it returns ‘true’
Option b- print(“Hello World”)
34. Guess the output of the following code:
class myclass():
def __len__(self):
return 0
myobj = myclass()
print(bool(myobj))
a) False
b) True
c) Error message
d) None of the above
Ans: a) False
Object from a class with __len__ function returning 0 or ‘False’, evaluates to ‘False’
Option b- print(“Hello World”)
35. Function used to determine if an object is of certain data type is:
a) format()
b) format_map()
c) ljust()
d) isinstance()
Ans: d) isinstance()
Option b- print(“Hello World”)
CHAPTER 4: OPERATORS AND COLLECTION DATA TYPE
36. Operators which are used to test if a sequence is present in an object are called
a) Identity operators
b) Comparison operators
c) Membership operators
d) Logical operators
Ans: c) Membership operators
37. In the expression x ** y, what is the ‘**’ operator and if x=2 and y=5, what value will it return?
a) Multiplication, 10
b) Exponential, 10
c) Exponential, 32
d) Exponential, 25
Ans: c) Exponential, 32
38. Which one of the following is collection data type in Python?
a) Set
b) List
c) Tuple
d) All of the above
Ans: d) All of the above
39. Which collection data type in Python is ordered, changeable, and allows duplicate members?
a) Set
b) List
c) Tuple
d) Dictionary
Ans: b) List
40. Which collection data type in Python is ordered, unchangeable, and allows duplicate members?
a) Set
b) List
c) Tuple
d) Dictionary
Ans: c) Tuple
41. Which collection data type in Python is unordered, unchangeable, and allows no duplicate members?
a) Set
b) List
c) Tuple
d) Dictionary
Ans: a) Set
42. Which collection data type in Python is ordered, changeable, and allows no duplicate members?
a) Set
b) List
c) Tuple
d) Dictionary
Ans: d) Dictionary
43. Guess the output of the following code:
mylist = [“carrot”, “peas”, “beans”]
print(mylist[1:])
a) [‘carrot’, ‘peas’]
b) [‘peas’]
c) [‘peas’, ‘beans’]
d) [‘carrot’, ‘beans’]
Ans: c) [‘peas’, ‘beans’], returns the items from 1st index ‘peas’, as index 0 is first item
44. Method used to insert a new list item without replacing any of the existing values in the list is
a) insert()
b) modify()
c) append()
d) format()
Ans: a) insert()
45. Method used to insert a new list item at the end of the list is:
a) insert()
b) modify()
c) append()
d) format()
Ans: c) append()
46. Method used to append elements from another list to current list is:
a) append()
b) extend()
c) modify()
d) format()
Ans: b) extend()
47. Method used to remove a specific item from the list is:
a) remove()
b) pop()
c) del keyword
d) clear()
Ans: a) remove()
48. Which of the following will work similar to clear() function in Python?
a) remove()
b) pop()
c) del keyword
d) None of the above
Ans: c) del keyword
49. What does list comprehension do in Python?
a) It is used to loop through the list items
b) It offers a shorter syntax while creating new list, based on the values of the existing list
c) It is used to store multiple items in a single variable
d) It is used to make a dictionary
Ans: b) It offers a shorter syntax while creating new list, based on the values of the existing list
50. Guess the output of the following code:
mylist = [190, 40, 30, 24,100]
mylist.sort(reverse = True)
print(mylist)
a) 24, 30, 40, 100, 190
b) 24, 30, 40, 100, 000
c) 190, 100, 40, 30, 24
d) Error message
Ans: c) 190, 100, 40, 30, 24
51. Guess the output of the following code:
mylist = [“banana”, “Orange”, “Kiwi”, “cherry”]
mylist.reverse()
print(mylist)
a) [‘cherry’, ‘banana’, ‘Orange’, ‘Kiwi’]
b) [‘Orange’, ‘Kiwi’, ‘banana’, ‘cherry’]
c) [‘banana’, ‘Orange’, ‘Kiwi’, ‘cherry’]
d) [‘cherry’, ‘Kiwi’, ‘Orange’, ‘banana’]
Ans: d) [‘cherry’, ‘Kiwi’, ‘Orange’, ‘banana’]
52. What are the methods used to copy one list to another list?
a) copy()
b) list()
c) both a) and b)
d) None of the above
Ans: c) both a) and b)
53. Guess the output of the following code:
Mytuple = (“apple”, “banana”, “cherry”, “apple”, “cherry”)
print(Mytuple)
a) (‘cherry’, ‘banana’, ‘apple’)
b) (‘apple’, ‘banana’, ‘cherry’)
c) (‘cherry’, ‘apple’, ‘cherry’, ‘banana’, ‘apple’)
d) (‘apple’, ‘banana’, ‘cherry’, ‘apple’, ‘cherry’)
Ans: d) (‘apple’, ‘banana’, ‘cherry’, ‘apple’, ‘cherry’) , Tuples are ordered and allows duplicates
54. Guess the output of the following code:
Mytuple = (“sky”, “fly”, “my”, “bye”, “hi”, “my”, “fly”)
print(Mytuple[-4:-1])
a) (‘hi’, ‘my’, ‘fly’)
b) (‘bye’, ‘hi’, ‘my’)
c) (‘fly’, ‘my’, ‘hi’)
d) (‘my’, ‘hi’, ‘bye’)
Ans: b) (‘bye’, ‘hi’, ‘my’)
55. Creating a tuple and assigning values to it is called:
a) initialization
b) declaration
c) modifying
d) packing
Ans: d) packing
56. What are the methods used to loop through tuples in Python?
a) count()
b) range()
c) len()
d) both b) and c)
Ans: d) both b) and c)
57. Guess the output of the following code:
veges = (“carrot”, “peas”, “beans”)
thistuple = veges * 2
print(thistuple)
a) (‘carrot’, ‘peas’, ‘beans’, ‘carrot’, ‘peas’, ‘beans’)
b) (‘carrot’, ‘carrot’, ‘peas’, ‘peas’, ‘beans’, ‘beans’)
c) (‘carrot’, ‘peas’, ‘beans’)
d) Error message
Ans: a) (‘carrot’, ‘peas’, ‘beans’, ‘carrot’, ‘peas’, ‘beans’)
58. Guess the output of the following code:
myset = {“sky”, “my”, “fly”, “my”}
print(myset)
a) (‘sky’, ‘my’, ‘fly’)
b) (‘my’, ‘fly’, ‘sky’)
c) (‘fly’, ‘my’, ‘sky’)
d) All of the above
Ans: d) All of the above , Sets do not allow duplicates and are unordered
59. How to add items in the Sets in Python?
a) format()
b) modify()
c) add()
d) Once a set is created, we cannot be change the set
Ans: c) add()
60. How to remove a specific item from a set?
a) remove()
b) clear()
c) discard()
d) both a) and c)
Ans: d) both a) and c)
61. How to remove a random item from a set?
a) del keyword
b) pop()
c) clear()
d) remove()
Ans: b) pop()
62. We use _____ to add two sets:
a) copy()
b) union()
c) update()
d) both b) and c)
Ans: d) both b) and c)
63. Method which will keep only those items which are present in both sets
a) intersection()
b) symmetric_difference()
c) both a) and b)
d) None of these
Ans: a) intersection()
64. Method which will return a new set, and only keep the elements which are not present in both sides:
a) intersection()
b) symmetric_difference()
c) symmetric_difference_update()
d) None of these
Ans: b) symmetric_difference()
65. ______ method is used to create dictionary
a) dict()
b) create()
c) type()
d) None of these
Ans: a) dict()
66. _______ method is used to access items in dictionary
a) access()
b) keys()
c) get()
d) gets()
Ans: c) get()
67. “update() method is used to update the dictionary with the items from arguments”, state whether statement is true or false
a) True
b) False
c) Can’t be determined
d) None of the above
Ans: a) True
68. Guess the output of the following code:
mydisct = {
“manu”: 20230202,
“expire”: 20240101,
“brand”: “cadbury”
}
for x in mydisct.keys():
print(x)
for x in mydisct.values():
print(x)
a) manu
20230202
expire
20240101
brand
cadbury
b) manu
Expire
brand
20230202
20240101
cadbury
c) manu
expire
brand
20230202
20240101
cadbury
d) manu
expire
brand
20230202
20240101
Cadbury
Ans: c) manu
expire
brand
20230202
20240101
Cadbury
69. fromkeys() function is used to return:
a) Returns the value of specified keys
b) Returns a list of values in the dictionary
c) Returns a list containing dictionary’s keys
d) Returns the value of specified keys and values
Ans: d) Returns the value of specified keys and values
CHAPTER 5: CONDITIONS- IF ELSE, WHILE, FOR
70. Guess the output of the following code:
a = 111
b = 1111
if b > a:
print(“b is greater than a”)
a) b is greater than a
b) false
c) Error message
d) None of these
Ans: c) Error message, Indentation Error in the last line before print
71. _______ statement is used to avoid error, when if statement has no content.
a) pass
b) break
c) when
d) continue
Ans: a) pass
72. ________ statement is used to stop the loop when while condition is true.
a) else
b) elif
c) break
d) continue
Ans: c) break
73. ________ statement is used to stop the current iteration and further process the next one.
a) elif
b) pass
c) else
d) continue
Ans: d) continue
74. ________ statement is used to run the block of code when the condition is false.
a) break
b) else
c) continue
d) pass
Ans: b) else
75. __________ loop is used for iterating over a sequence
a) for
b) while
c) do- while
d) if-else
Ans: a) for
76. ___________ loop do not necessarily require indexing variable to loop over a sequence.
a) while
b) for
c) do-while
d) if-else
Ans: b) for
CHAPTER 6: FUNCTIONS
77. __________ is a block of code which runs when it is called.
a) functions
b) arguments
c) parameters
d) None of these
Ans: a) functions
78. Statement 1: A variable listed inside the parenthesis in the function definition is called parameter.
Statement 2: A value that is sent to the function when it is called, is known as argument.
a) Statement 1 is true and Statement 2 is false
b) Statement 1 is false and Statement 2 is true
c) Statement 1 and Statement 2 is false
d) Statement 1 is true and Statement 2 is true
Ans: d) Statement 1 is true and Statement 2 is true
79. Guess the output of the following code:
def myfunc (word1, word2):
print(word1 + “ ” + word2)
myfunc(“Hello”)
a) Hello
b) HelloWorld
c) Hello World
d) Error message
Ans: d) Error message, 2nd value for 2nd parameter is not given
80. Guess the output of the following code:
def myfunc (*word):
print(word[1] + “are the words” )
myfunc(“Hello”, “World”, “is”)
a) Hello World is
b) World
c) Hello
d) Error message
Ans: b) World
81. Statement used to give a result of the function is:
a) output
b) result
c) return
d) None of these
Ans: c) return
82. Function calling itself in Python is:
a) recursion
b) loop
c) conditional statement
d) infinite loop
Ans: a) recursion
CHAPTER 7: LAMBDA
83. A small anonymous function is called:
a) recursion
b) lambda
c) for loop
d) goto
Ans: b) lambda
84. Statement 1: Lambda function can take any number of arguments, but can have only one expression.
Statement 2: Do not use lambda function when an anonymous function is required for a short period of time
a) Statement 1 and Statement 2 are false
b) Statement 1 and Statement 2 are true
c) Statement 1 is false and Statement 2 is true
d) Statement 1 is true and Statement 2 is false
Ans: d) Statement 1 is true and Statement 2 is false
85. Guess the output of the following code:
def func(y)
return lambda x: x * y
mul_func = func(4)
print(mul_func(12))
a) 4
b) 12
c) 48
d) Error message
Ans: c) 48
CHAPTER 8: ARRAYS
86. Statement 1: Python does not have built-in support for arrays, instead can use lists for arrays
Statement 2: Arrays can store more than one value in one single variable
a) Statement 1 and Statement 2 are false
b) Statement 1 and Statement 2 are true
c) Statement 1 is false and Statement 2 is true
d) Statement 1 is true and Statement 2 is false
Ans: b) Statement 1 and Statement 2 are true
87. _______ method is used to return the number of elements in an array.
a) len()
b) count()
c) return()
d) index()
Ans: a) len()
88. Guess the output of the following code:
fruits = [“grapes”, “coconut”, “mango”]
fruits[0] = “strawberry”
print(fruits)
a) [‘grapes’, ‘coconut’, ‘mango’]
b) strawberry
c) [‘strawberry’, ‘coconut’, ‘mango’]
d) Error message
Ans: c) [‘strawberry’, ‘coconut’, ‘mango’]
89. Guess the output of the following code:
fruits = [“grapes”, “coconut”, “mango”]
fruits.append(“strawberry”)
print(fruits)
a) [‘grapes’, ‘coconut’, ‘mango’]
b) [‘grapes’, ‘strawberry’, ‘coconut’, ‘mango’]
c) [‘strawberry’, ‘coconut’, ‘mango’]
d) [‘grapes’, ‘coconut’, ‘mango’, ‘strawberry’]
Ans: d) [‘grapes’, ‘coconut’, ‘mango’, ‘strawberry’]
90. Guess the output of the following code:
fruits = [“grapes”, “coconut”, “mango”]
fruits.pop(1)
print(fruits)
a) [‘coconut’]
b) [‘grapes’, ‘coconut’]
c) [‘grapes’, ‘mango’]
d) [‘coconut’, ‘mango’]
Ans: b) [‘grapes’, ‘coconut’]
91. Guess the output of the following code:
fruits = [“grapes”, “coconut”, “mango”]
fruits.remove(“coconut”)
print(fruits)
a) [‘mango’, ‘grapes’]
b) [‘grapes’, ‘coconut’]
c) [‘coconut’, ‘mango’]
d) [‘grapes’, ‘mango’]
Ans: d) [‘grapes’, ‘mango’]
CHAPTER 9: CLASSES AND OBJECTS
92. Function which is always executed when the class is being initiated is called:
a) __init__()
b) __str__()
c) def
d) class()
Ans: a) __init__()
93. Function that controls the return value when class object is a string:
a) string()
b) __str__()
c) return
d) class()
Ans: b) __str__()
94. “To create a class, we use the keyword def”, state whether the statement is true or false.
a) False
b) True
c) No such keyword exists
d) We can’t create class in Python
Ans: a) False, To create a class we use the keyword ‘class’
95. “The __init__() function is invoked every time the object is created using the class” state whether the statement is true or false.
a) False
b) True
c) No such function exists
d) We can’t create class in Python
Ans: b) True
96. _______ parameter is the current instance of the class and used to access class variables.
a) pass
b) key
c) self
d) None of these
Ans: c) self
97. The correct syntax for deleting object properties, if p1 is the object and age is a property
a) del p1.age
b) del p1
c) both a) and b)
d) We can’t delete object properties
Ans: a) del p1.age
98. The correct syntax for deleting object of a class, if p1 is the object and age is a property
a) del p1.age
b) del p1
c) both a) and b)
d) We can’t delete object properties
Ans: b) del p1
CHAPTER 10: INHERITANCE
99. ________ allows us to create a class that can acquire all the methods and properties of another class
a) Data mining
b) Encapsulation
c) Polymorphism
d) Inheritance
Ans: d) Inheritance
100. Parent class is also called _________.
a) base class
b) derived class
c) both a) and b)
d) None of these
Ans: a) base class
101. Child class is also called _________.
a) base class
b) derived class
c) both a) and b)
d) None of these
Ans: b) derived class
102. _______ function is used to make child all methods and properties without using the name of the parent element.
a) super()
b) __init__()
c) class()
d) child()
Ans: a) super()
103. “If a method is added to the child class having same name as a function in parent class, then the inheritance of the parent method will be overridden”, state whether the statement is true or false.
a) True
b) False
c) Child class function can’t have the same name as function in parent class
d) None of these
Ans: a) True
CHAPTER 11: ITERATORS
104. Objects that contain countable number of values are called ________.
a) iterables
b) arrays
c) tuples
d) iterators
Ans: d) iterators
105. iter() and next() method are a part of _______.
a) iterables
b) arrays
c) tuples
d) iterators
Ans: d) iterators
106. ________ loop is used to iterate through iterable objects
a) while
b) if-else
c) for
d) do while
Ans: c) for
107. _______ method is used to do operations and returns the iterator object itself
a) iter()
b) next()
c) init()
d) None of these
Ans: a) iter()
108. _______ method is used to do operations and returns the next item in the sequence
a) iter()
b) next()
c) init()
d) None of these
Ans: b) next()
109. Statement used to prevent infinite and forever iteration is:
a) pass
b) break
c) StopIteration
d) continue
Ans: c) StopIteration
CHAPTER 12: POLYMORPHISM
110. __________ means having multiple forms.
a) Data mining
b) Encapsulation
c) Inheritance
d) Polymorphism
Ans: d) Polymorphism
111. Use of len() function in strings is:
a) to return the number of characters
b) to return the number of items
c) to return the number of key or value pairs
d) None of these
Ans: a) to return the number of characters
112. Use of len() function in tuples is:
a) to return the number of characters
b) to return the number of items
c) to return the number of key or value pairs
d) None of these
Ans: b) to return the number of items
113. Use of len() function in dictionary is:
a) to return the number of characters
b) to return the number of items
c) to return the number of key or value pairs
d) None of these
Ans: c) to return the number of key or value pairs
114. “With the help of polymorphism we can execute the same method of all classes, that is child class and parent class”, state whether the statement is true or false.
a) True
b) False
c) Child class function can’t have the same name as function in parent class
d) None of these
Ans: a) True
CHAPTER 13: LOCAL AND GLOBAL SCOPE
115. A variable created inside a function and has a scope only inside that function is called:
a) global variable
b) static variable
c) local variable
d) None of these
Ans: c) local variable
116. A variable created in the main body of Python function and has a scope on both outside and inside the function is called:
a) global variable
b) static variable
c) local variable
d) None of these
Ans: a) global variable
117. _______ helps to make a variable global and also helps to change the value of global variable inside the function.
a) local
b) global
c) static
d) None of these
Ans: b) global
118. Guess the output of the code:
X = 500
def func1():
global X
X = 200
func1()
print(X)
a) Error message
b) 700
c) 500
d) 200
Ans: d) 200
CHAPTER 14: MODULES
119. Modules are similar to _______.
a) Methods
b) Functions
c) Code library
d) All of the above
Ans: d) All of the above
120. A file containing a set of functions is called ______.
a) Modules
b) Tuples
c) Lists
d) None of these
Ans: a) Modules
121. File extension used to create modules in Python is_______.
a) .java
b) .cpp
c) .c
d) .py
Ans: d) .py
122. Statement used to access the module in Python is:
a) format
b) def
c) import
d) self
Ans: c) import
123. Function used to list all the functions present in a module is:
a) extract()
b) pop()
c) len()
d) dir()
Ans: d) dir()
CHAPTER 15: MATH FUNCTIONS
124. _____ and ______ functions in Python can be used to find the lowest and the highest value of the iterable.
a) min() and max()
b) max() and min()
c) floor() and ceil()
d) ceil() and floor()
Ans: a) min() and max()
125. What does abs() math function do in Python?
a) The function returns whole numbers for the input values
b) The function returns nearest rounded values for the input values
c) The function returns positive values for the input values
d) The function returns maximum values for the input values
Ans: c) The function returns positive values for the input values
CHAPTER 16: PYTHON JSON
126. What does JSON stands for?
a) Java object notation
b) JavaScript object notation
c) Jupyter object notation
d) None of these
Ans: b) JavaScript object notation
127. Method used to convert JSON to Python:
a) json.parse()
b) json.dumps()
c) json.loads()
d) None of the above
Ans: c) json.loads()
128. Method used to convert Python to JSON:
a) json.parse()
b) json.dumps()
c) json.loads()
d) None of the above
Ans: b) json.dumps()
129. ‘dict’ Python objects converted into JSON equivalent:
a) arrays
b) number
c) object
d) string
Ans: c) object
130. ‘str’ Python objects converted into JSON equivalent:
a) arrays
b) number
c) object
d) string
Ans: d) string
131. ‘list’, ‘tuple’ Python objects converted into JSON equivalent:
a) arrays
b) number
c) object
d) string
Ans: a) arrays
132. ‘none’ Python objects converted into JSON equivalent:
a) arrays
b) number
c) null
d) string
Ans: c) null
CHAPTER 17: PYTHON RegEx AND EXCEPTION
133. RegEx stands for:
a) Regular Explanation
b) Regular Expression
c) Real Expression
d) Real Equation
Ans: b) Regular Expression
134. “RegEx is used to search for a specific pattern in a sequence of characters”, state whether the statement is true or false.
a) True
b) False
Ans: a) True
135. Function contains a list of all matches in re module is:
a) findall()
b) search()
c) split()
d) sub()
Ans: a) findall()
136. Function contains returns a match object if there is match anywhere in the string is:
a) findall()
b) search()
c) split()
d) sub()
Ans: b) search()
137. Function returns a list where string has been split at each match is:
a) findall()
b) search()
c) split()
d) sub()
Ans: c) split()
138. Function replaces one or many matches with a string is:
a) findall()
b) search()
c) split()
d) sub()
Ans: d) sub()
139. PIP in Python programming language stands for:
a) Preferred Installer Package
b) Preferred Installer Program
c) Python Installer Package
d) Python Installer Program
Ans: b) Preferred Installer Program
140. ______ is the command used to list all the packages installed in the system.
a) extract
b) parse
c) list
d) def
Ans: c) list
141. How to remove a package?
a) Delete the package
b) Hide the package
c) Drop the package
d) Uninstall the package
Ans: d) Uninstall the package
142. _______ block informs to test the block of code for errors
a) try
b) except
c) else
d) finally
Ans: a) try
143. ________ block handles the error
a) try
b) except
c) else
d) finally
Ans: b) except
144. _________ block executes the code when there is no error
a) try
b) except
c) else
d) finally
Ans: c) else
145. _________ block executes the code, regardless of the result from the try and except blocks
a) try
b) except
c) else
d) finally
Ans: d) finally
146. __________ keyword defines what error to raise, and the text to print to the user
a) raise
b) parse
c) throw
d) catch
Ans: a) raise
147. Which of the following functions used for user input?
a) input()
b) raw_input()
c) insert()
d) both a) and b)
Ans: d) both a) and b)
148. Guess the output of the code:
try:
print(x)
except:
print(“Variable not defined”)
else:
print(“Something else went wrong”)
a) Variable not defined
b) Something else went wrong
c) Error message
d) None of these
Ans: a) Variable not defined , variable ‘x’ is not defined in the program
149. Guess the output of the code:
try:
print(“Hi”)
except:
print(“Something went wrong”)
else:
print(“Nothing went wrong”)
a) Something went wrong
b) Nothing went wrong
c) Hi
Nothing went wrong
d) Error message
Ans: c) Hi
Nothing went wrong
Here no error is there in the code, so the string ‘Hello’ gets printed and the else statement also gets printed
150. Guess the output of the code:
try:
print(x)
except:
print(“Something went wrong”)
finally:
print(“The try-except is completed”)
a) Something went wrong
b) Something went wrong
The try-except is completed
c) The try-except is completed
d) Error message
Ans: b) Something went wrong
The try-except is completed
‘finally block’ gets executed, if defined, whether the ‘try block’ raises and error or not
151. Guess the output of the code:
x = “Hello World”
if not type(x) is int:
raise TypeError(“Only integers are allowed”)
a) Hello World
b) Hello World
Only integers are allowed
c) Only integers are allowed
d) TypeError: Only integers are allowed
Ans: d) TypeError: Only integers are allowed
Raise keyword is used to raise an exception
152. ________ is the method that allows user input in Python.
a) insert()
b) input()
c) raw_input()
d) both b) and c)
Ans: d) both b) and c), input() method is used in Python 3.6 and raw_input method is used in Python 2.7
CHAPTER 18: STRING FORMATTING
153. ________ method allows user to format selected part of the string in Python.
a) insert()
b) format()
c) append()
d) input()
Ans: b) format()
154. ___ placeholders are used in the text, to run values through the format() method for parts of the string in Python.
a) () – parenthesis
b) [] – square brackets
c) {} – curly braces
d) < > – angular brackets
Ans: c) {} – curly braces
155. Guess the output of the code:
cost = 104
txt = “The price is { : .2f} dollars”
print(txt.fomat(price))
a) The price is 104.00 dollars
b) 104.00
c) The price is { : .2f} dollars
d) 104
Ans: a) The price is 104.00 dollars
156. Guess the output of the code:
quantity = 4
itemid = 101
price = 20
theorder = “{0} items were ordered, having item id as {1}, and total amount of the order is {:.2f} rupees”
print(myorder.format(quantity, itemid, price))
a) {0} items were ordered, having item id as {1}, and total amount of the order is {:.2f} rupees
b) quantity items were ordered, having item id as itemid, and total amount of the order is price rupees
c) 4 items were ordered, having item id as 101, and total amount of the order is 20 rupees
d) 4 items were ordered, having item id as 101, and total amount of the order is 20.00 rupees
Ans: d) 4 items were ordered, having item id as 101, and total amount of the order is 20.00 rupees
CHAPTER 19: FILE HANDLING
157. What are the two parameters which open() function takes in Python?
a) textmode and filemode
b) filesetting and filemode
c) filename and mode
d) filetype and filesetting
Ans: c) filename and mode
158. ___ is the default mode while opening a file in Python.
a) read
b) write
c) append
d) create
Ans: a) read, read mode – r is the default mode of opening a file
159. ______ mode opens a file for reading, error occurs when file doesn’t exist
a) r
b) w
c) a
d) x
Ans: a) r, r stands for read mode
160. ______ mode opens a file for appending, creates a file if it doesn’t exist
a) r
b) w
c) a
d) x
Ans: c) a, stands for append mode
161. ______ mode opens a file for writing, creates a file if it doesn’t exist
a) r
b) w
c) a
d) x
Ans: b) w, w stands for write mode
162. ______ mode creates the specified file, error occurs when file exists
a) r
b) w
c) a
d) x
Ans: d) x, x stands for create mode.
163. _______ is the mode to open a text file
a) t
b) b
c) both a) and b)
d) None of the above
Ans: a) t, t stand for text mode
164. _______ is the mode to open a binary file
a) t
b) b
c) both a) and b)
d) None of the above
Ans: b) b , b stands for binary mode
165. _________ method is used to return one line after reading the file.
a) return()
b) returnline()
c) readline()
d) read()
Ans: c) readline()
166. Find the correct syntax for closing a file from the following:
a) f = close(demofile.txt, r)
b) f = close(“demofile.txt”, “r”)
c) f.close(“demofile.txt”, “r”)
d) f.close()
Ans: d) f.close()
167. Find the correct syntax for opening a file in read mode from the following:
a) f.open(“demofile.txt”, “r”)
b) f.open = (“demofile.txt”, “r”)
c) f = open(“demofile.txt”, “r”)
d) f.open(‘r’)
Ans: c) f = open(“demofile.txt”, “r”)
168. Find the correct syntax for writing in a file from the following:
a) f.write(“demofile.txt”, “w”)
b) f.write = (“demofile.txt”, “w”)
c) f = write(“demofile.txt”, “w”)
d) f.write(“This is a file”)
Ans: d) f.write(“This is a file”)
169. ___________ method used to delete a file.
a) remove()
b) os.remove()
c) rmdir()
d) os.rmdir()
Ans: b) os.remove()
170. ___________ method used to delete an entire folder.
a) os.rmdir()
b) os.remove()
c) rmdir()
d) remove()
Ans: a) os.rmdir()
CHAPTER 20: PYTHON MODULES – NUMPY
171. NumPy stands for ________ in Python.
a) Numeric Python
b) Numerical Python
c) Number Python
d) Name Python
Ans: b) Numerical Python
172. The main purpose of NumPy in Python is:
a) to analyze data
b) for scientific computation
c) used to build webpages
d) working with arrays
Ans: d) working with arrays
173. Array object in Numpy is called_______
a) nparray
b) narray
c) ndarray
d) array
Ans: c) ndarray
174. Statement 1: NumPy faster than Lists
Statement 2: NumPy arrays are stored in a contiguous memory location and processes can access and manipulate faster.
a) Statement 1 is true and Statement 2 is false.
b) Statement 1 is true and Statement 2 is the explanation of Statement 1.
c) Statement 1 is false and Statement 2 is true is not the explanation of Statement 1.
d) Statement 1 is false and Statement 2 is also false
Ans: b) Statement 1 is true and Statement 2 is the explanation of Statement 1.
175. NumPy is written in which language?
a) Python
b) C, C++
c) JAVA
d) Python, C, C++
Ans: d) Python, C, C++
176. _______ is method to identify the type of object passed through it.
a) identify()
b) object()
c) type()
d) None of the above
Ans: c) type()
177. 0 – D arrays are also called _______.
a) Uni – dimensional
b) Scalar
c) Matrices
d) None of these
Ans: b) Scalar
178. 1 – D arrays are also called _______.
a) Uni – dimensional
b) Scalar
c) Matrices
d) None of these
Ans: a) Uni – dimensional
179. 2 – D arrays are also called as ________.
a) Uni – dimensional
b) Scalar
c) Matrices
d) None of these
Ans: c) Matrices
180. ________ attribute is used to find how many dimensions an array has, in Python.
a) array
b) nparray
c) ndarray
d) ndim
Ans: d) ndim
181. “Slicing in Python means taking values from one index number to another in an array”, state whether true or false.
a) True
b) False
c) Python doesn’t support arrays
d) None of these
Ans: a) True
182. Guess the output of the following code:
import numpy as np
arr = np.array([[1, 2, 3, 4, 5, 6], [7, 8, 9,10,11,12]])
print(arr[1, 1:4])
a) [1 2 3]
b) [2 3 4]
c) [7 8 9]
d) [8 9 10]
Ans: d) [8 9 10]
183. Guess the output of the following code:
import numpy as np
arr = np.array([1, 2, 3, 4, 5, 6])
print(arr[-3:-1])
a) [1 2]
b) [3 4]
c) [4 5]
d) [5 6]
Ans: c) [4 5], this refers to the index from the end, the third index from the end is 4 and the 1st index 5
184. Guess the output of the following code:
import numpy as np
arr = np.array([1, 2, 3, 4, 5, 6])
print(arr[1:5:2])
a) [1 2 3 4]
b) [2 3 4 5]
c) [ 2 4 ]
d) [2 4 6]
Ans: c) [ 2 4 ], Takes the values between index 1 to index 5 and the step or the number skip is 2, the index 5 value is excluded.
185. Guess the output of the following code:
import numpy as np
arr = np.array([1, 2, 3, 4, 5, 6])
print(arr[:4])
a) [1 2 3 4]
b) [2 3 4 5]
c) [1 2 3 4 5]
d) [2 3 4 5 6]
Ans: a) [1 2 3 4], Takes the values from start i.e, index 0, till index 4, but excluding index 4, i.e, 5. This is an example of slicing method in Python for arrays.
186. Guess the output of the following code:
import numpy as np
arr = np.array([1, 2, 3, 4, 5, 6])
print(arr[1:5])
a) [1 2 3 4]
b) [2 3 4 5]
c) [1 2 3 4 5]
d) [2 3 4 5 6]
Ans: b) [2 3 4 5], Takes the value from index 1, i.e, ‘1’ till index 5, but excluding index 5, i.e, 6. This is slicing method in Python for arrays.
187. __________ data type is used to represent text data in NumPy.
a) strings
b) string
c) integer
d) complex
Ans: a) strings
188. __________ data type is used to represent integer numbers in NumPy.
a) strings
b) float
c) integer
d) complex
Ans: c) integer
189. __________ data type is used to represent real numbers in NumPy.
a) strings
b) float
c) integer
d) complex
Ans: b) float
190. __________ data type is used to represent complex numbers in NumPy.
a) strings
b) float
c) integer
d) complex
Ans: d) complex
191. __________ data type is used to represent true or false in NumPy.
a) strings
b) float
c) boolean
d) complex
Ans: c) Boolean
192. Character used to represent data type integer:
a) i
b) m
c) u
d) b
Ans: a) i
193. Character used to represent data type unsigned integer:
a) i
b) m
c) u
d) U
Ans: c) u
194. Character used to represent data type boolean:
a) i
b) m
c) u
d) b
Ans: d) b
195. Character used to represent data type integer timedelta:
a) i
b) m
c) u
d) b
Ans: b) m
196. Character used to represent data type datetime:
a) f
b) m
c) b
d) M
Ans: d) M
197. Character used to represent data type float:
a) f
b) m
c) b
d) M
Ans: a) f
198. Character used to represent data type complex float:
a) f
b) U
c) c
d) u
Ans: c) c
199. Character used to represent data type object:
a) o
b) u
c) O
d) b
Ans: c) O
200. Character used to represent data type string:
a) S
b) s
c) u
d) b
Ans: a) S
201. Character used to represent data type unicode string :
a) u
b) m
c) U
d) b
Ans: c) U
202. Character used to represent data type which is fixed chunk of memory of other data type void:
a) o
b) O
c) v
d) V
Ans: d) V
203. ________ is used to define the data type of array elements.
a) ndarray
b) ndtype
c) darray
d) dtype
Ans: d) dtype
204. Guess the output of the following code:
import numpy as np
arr = np.array ([‘a’, ‘41’, ‘43’], dtype = ‘i’)
a) [0 41 43]
b) [a 41 43]
c) [41 43]
d) ValueError
Ans: d) ValueError, as ‘a’ is a non-integer, and NumPy is unable to type-cast it
205. Statement 1: astype() function creates a copy of the array
Statement 2: astype() function allows to specify datatype as parameter
a) Statement 1 is true and Statement 2 is false
b) Statement 1 is false and Statement 2 is true
c) Statement 1 is true and Statement 2 is true
d) Statement 1 is false and Statement 2 is false
Ans: c) Statement 1 is true and Statement 2 is true
206. The difference between copy and view is:
a) Copy has the copy of the original array, and view is the view of original array
b) Changes made in copy will not change original values of the array
c) Changes made in view will change the values of the original array
d) All of the above
Ans: d) All of the above
207. ______ attribute is used to find whether the array owns the data or not.
a) base
b) None
c) check
d) find
Ans: a) base
208. “base attribute returns None if arrays own the data and refers to the original object if it doesn’t”, State whether true or false.
a) True
b) False
c) base attribute doesn’t exist in Python
d) None of the above
Ans: a) True
209. Guess the output of the following code:
import numpy as np
ar = np.array([0, 1, 2, 3, 4])
x = ar.copy()
y = ar.view()
print(x.base)
print(y.base)
a) [0 1 2 3 4]
b) [0 1 2 3 4]
None
c) None
[0 1 2 3 4]
d) None
Ans: c) None
[0 1 2 3 4]
210. _______ attribute returns a tuple with index numbers with respective number of elements.
a) tuple
b) shape
c) base
d) np.array
Ans: b) shape
211. What does flattening of array mean?
a) Converting multi-dimensional array to 0 -D array
b) Converting 0 –D array to multi-dimensional array
c) Converting multi-dimensional array to 1-D array
d) Converting 1 -D array to 0 -D array
Ans: c) Converting multi-dimensional array to 1-D array
212. We can use ______ function for flattening the array.
a) reshape()
b) reshape(0)
c) reshape(1)
d) reshape(-1)
Ans: d) reshape(-1)
213. ______ is used to iterate through array in NumPy.
a) for
b) while
c) do while
d) if else
Ans: a) for
214. Guess the output for the following code:
import numpy as np
arr1 = np.array([1, 2, 3])
for y in arr1:
print(y)
a) 3
b) 1
2
3
c) 2
3
d) 2
Ans: b) 1
2
3
215. Guess the output for the following code:
import numpy as np
arr1 = np.array([[1, 2, 3], [4, 5, 6]])
for y in arr1:
print(y)
a) 1
2
3
4
5
6
b) 1 2 3
4 5 6
c) [1 2 3]
[4 5 6]
d) [4 5 6]
Ans: c) [1 2 3]
[4 5 6]
216. Guess the output for the following code:
import numpy as np
arr1 = np.array([[1, 2, 3], [4, 5, 6]])
for x in arr1:
for y in x:
print(y)
a) 1
2
3
4
5
6
b) 1 2 3
4 5 6
c) [1 2 3]
[4 5 6]
d) [4 5 6]
Ans: a) 1
2
3
4
5
6, returns actual values, and iterates the array in each dimension
217. _______ function used for advanced iterations
a) for()
b) iter()
c) nditer()
d) niter()
Ans: c) nditer()
218. Mentioning sequence number for something one by one is called:
a) Sequencing
b) Enumeration
c) Flattening
d) None of the above
Ans: b) Enumeration
219. _______ method is used when index of an element is required for iterating.
a) enumerate()
b) ndenumerate()
c) nditer()
d) niter()
Ans: b) ndenumerate()
220. In NumPy we join arrays using _______
a) keys
b) unique key
c) primary axes
d) axes
Ans: d) axes
221. The function used to join the sequence of arrays is:
a) join()
b) concatenate()
c) array(array1 + array2)
d) None of the above
Ans: b) concatenate()
222. The default value of axis, if axis is not explicitly passed is:
a) 1
b) 2
c) 0
d) -1
Ans: c) 0
223. “Stacking and concatenation are same, but stacking is done on a new axis” state whether true or false.
a) True
b) False
c) Stacking is not a part of NumPy
d) None of the above
Ans: a) True
224. Stacking is done by ______ method in NumPy
a) stack()
b) hstack()
c) vstack()
d) dstack()
Ans:
225. Stacking along the rows is done by ______ method in NumPy
a) stack()
b) hstack()
c) vstack()
d) dstack()
Ans: b) hstack()
226. Stacking along the columns is done by ______ method in NumPy
a) stack()
b) hstack()
c) vstack()
d) dstack()
Ans: c) vstack()
227. Stacking along height or depth is done by ______ method in NumPy
a) stack()
b) hstack()
c) vstack()
d) dstack()
Ans: d) dstack()
228. Guess the output of the following code:
import numpy as npy
ar1 = npy.array([1, 2, 3])
ar2 = npy.array([4, 5, 6])
ar = npy.stack((ar1, ar2), axis = 1)
print(ar)
a)[[1 4]
[2 5]
[3 6]]
b) [1 2 3 4 5 6]
c) [[1 2 3]
[4 5 6]]
d) [[[1 4]
[2 5]
[3 6]]]
Ans: a)[[1 4]
[2 5]
[3 6]]
229. Guess the output of the following code:
import numpy as npy
ar1 = npy.array([1, 2, 3])
ar2 = npy.array([4, 5, 6])
ar = npy.hstack((ar1, ar2))
print(ar)
a)[[1 4]
[2 5]
[3 6]]
b) [1 2 3 4 5 6]
c) [[1 2 3]
[4 5 6]]
d) [[[1 4]
[2 5]
[3 6]]]
Ans: b) [1 2 3 4 5 6]
230. Guess the output of the following code:
import numpy as npy
ar1 = npy.array([1, 2, 3])
ar2 = npy.array([4, 5, 6])
ar = npy.vstack((ar1, ar2))
print(ar)
a)[[1 4]
[2 5]
[3 6]]
b) [1 2 3 4 5 6]
c) [[1 2 3]
[4 5 6]]
d) [[[1 4]
[2 5]
[3 6]]]
Ans: c) [[1 2 3]
[4 5 6]]
231. Guess the output of the following code:
import numpy as npy
ar1 = npy.array([1, 2, 3])
ar2 = npy.array([4, 5, 6])
ar = npy.dstack((ar1, ar2))
print(ar)
a)[[1 4]
[2 5]
[3 6]]
b) [1 2 3 4 5 6]
c) [[1 2 3]
[4 5 6]]
d) [[[1 4]
[2 5]
[3 6]]]
Ans: d) [[[1 4]
[2 5]
[3 6]]]
232. ________ method is used for splitting arrays.
a) slit()
b) splitarray()
c) array_split()
d) arraysplit()
Ans: c) array_split()
234. ________ method is used for splitting arrays along the rows.
a) array_split()
b) hsplit()
c) vsplit()
d) dsplit()
Ans: b) hsplit()
235. ________ method is used for splitting arrays along the columns.
a) array_split()
b) hsplit()
c) vsplit()
d) dsplit()
Ans: c) vsplit()
236. ________ method is used for splitting arrays along the depth or height.
a) array_split()
b) hsplit()
c) vsplit()
d) dsplit()
Ans: d) dsplit()
237. Guess the output of the following code:
import numpy as npy
ar = npy.array([1, 2, 3, 4, 5, 6])
narr = npy.array_split(arr, 3)
print(narr)
a) [array([1, 2]), array([3, 4]), array([5, 6])]
b) [array([1, 2]), array([3, 4]), array([5]), array([6])]
c) [1 2]
[3 4]
[5 6]
d) [array([[1, 2, 3],
[4, 5, 6]]), array([[7, 8, 9],
[10, 11, 12]]), array([[13, 14, 15],
[[16, 17, 18]])]
Ans: a) [array([1, 2]), array([3, 4]), array([5, 6])]
238. Guess the output of the following code:
import numpy as npy
ar = npy.array([1, 2, 3, 4, 5, 6])
narr = npy.array_split(arr, 4)
print(narr)
a) [array([1, 2]), array([3, 4]), array([5, 6])]
b) [array([1, 2]), array([3, 4]), array([5]), array([6])]
c) [1 2]
[3 4]
[5 6]
d) [array([[1, 2, 3],
[4, 5, 6]]), array([[7, 8, 9],
[10, 11, 12]]), array([[13, 14, 15],
[[16, 17, 18]])]
Ans: b) [array([1, 2]), array([3, 4]), array([5]), array([6])]
239. Guess the output of the following code:
import numpy as npy
ar = npy.array([1, 2, 3, 4, 5, 6])
narr = npy.array_split(arr, 3)
print(ar[0])
print(ar[1])
print(ar[2])
a) [array([1, 2]), array([3, 4]), array([5, 6])]
b) [array([1, 2]), array([3, 4]), array([5]), array([6])]
c) [1 2]
[3 4]
[5 6]
d) [array([[1, 2, 3],
[4, 5, 6]]), array([[7, 8, 9],
[10, 11, 12]]), array([[13, 14, 15],
[[16, 17, 18]])]
Ans: c) [1 2]
[3 4]
[5 6]
240. Guess the output of the following code:
import numpy as npy
ar = npy.array([1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12], [13, 14, 15], [16, 17, 18])
narr = npy.array_split(arr, 3)
print(narr)
a) [array([1, 2]), array([3, 4]), array([5, 6])]
b) [array([1, 2]), array([3, 4]), array([5]), array([6])]
c) [1 2]
[3 4]
[5 6]
d) [array([[1, 2, 3],
[4, 5, 6]]), array([[7, 8, 9],
[10, 11, 12]]), array([[13, 14, 15],
[[16, 17, 18]])]
Ans: d) [array([[1, 2, 3],
[4, 5, 6]]), array([[7, 8, 9],
[10, 11, 12]]), array([[13, 14, 15],
[[16, 17, 18]])]
241. The method used to search an array and return in indexes that get matched is:
a) search()
b) where()
c) sortedsearch()
d) find()
Ans: b) where()
242. The method used to search an arranged array and is used on binary search is:
a) search()
b) where()
c) searchsorted()
d) find()
Ans: c) searchsorted()
243. Find the output of the following code:
import numpy as npy
ar = npy.array([1, 2, 3, 4, 5, 6])
x = npy.where(arr%2 == 0)
print(x)
a) (array([1, 2, 3, 4, 5, 6, 7]),)
b) (array([1, 3, 5, 7]),)
c) (array([2, 4, 6]),)
d) (array([0, 2, 4, 6]),)
Ans: b) (array([1, 3, 5, 7]),), this is an example of program where the indexes values are even.
244. Find the output of the following code:
import numpy as npy
ar = npy.array([1, 2, 3, 4, 5, 6])
x = npy.where(arr%2 == 1)
print(x)
a) (array([1, 2, 3, 4, 5, 6, 7]),)
b) (array([1, 3, 5, 7]),)
c) (array([2, 4, 6]),)
d) (array([0, 2, 4, 6]),)
Ans: d) (array([0, 2, 4, 6]),), this is an example of program where the indexes values are odd.
245. The function to sort arrays in Numpy is:
a) sort_array()
b) arraysort()
c) sort()
d) sortarray()
Ans: c) sort()
246. Find the output of the following code:
import numpy as npy
ar1 = npy.array([32, 41, 11, 13])
print(npy.sort(ar1))
a) [11 13 32 41]
b) [11 13 32]
c) [41 32 13 11]
d) [41 32 13]
Ans: a) [11 13 32 41]
247. Find the output of the following code:
import numpy as npy
ar1 = npy.array([‘axe’, ‘knife’, ‘bullet’])
print(npy.sort(ar1))
a) [‘knife’ ‘bullet’ ‘axe’]
b) [‘axe’ ‘bullet’ ‘knife’]
c) [‘knife’ ‘axe’ ‘bullet’]
d) [‘bullet’ ‘knife’ ‘axe’]
Ans: b) [‘axe’ ‘bullet’ ‘knife’]
248. Find the output of the following code:
import numpy as npy
ar1 = npy.array([true, false, true])
print(npy.sort(ar1))
a) [true true false]
b) [false true]
c) [false true true]
d) None of the above
Ans: c) [false true true], this is an example to sort a boolean array
249. Find the output of the following code:
import numpy as npy
ar1 = npy.array([3, 2, 4], [5, 0, 1])
print(npy.sort(ar1))
a) [[ 2 3 4]
[1 0 5]]
b) [[ 3 2 4]
[0 1 5]]
c) [[ 2 3 4]
[0 1 5]]
d) None of the above
Ans: c) [[ 2 3 4]
[0 1 5]]
250. “Extracting elements out of the old array and creating new array out of them is called filtering” state whether true or false.
a) False
b) True
c) Filtering doesn’t exist in NumPy
d) None of the above
Ans: b) True
251. ________ is used for filtering array.
a) filter_list
b) array_filter list
c) index list
d) boolean index list
Ans: d) boolean index list
252. Find the output of the following code:
import numpy as npy
ar1 = npy.array([11, 12, 13, 14])
x = ar1[[True, False, True, False]]
print(x)
a) [11 13]
b) [11 12 13 14]
c) [12 14]
d) [12, 14]
Ans: a) [11 13], The boolean index list filters the values of the element in filtered array, if the index is true
253. Find the output of the following code:
import numpy as npy
ar1 = npy.array([11, 12, 13, 14])
filter_ar1 = ar1 > 12
newar1 = ar1[filter_ar1]
print(filter_ar1)
print(newar1)
a) [false true false true]
[11 12]
b) [false true false true]
[13 14]
c) [false false true true]
[13 14]
d) [false false true true]
[11 12]
Ans: c) [false false true true]
[13 14]
254. Find the output of the following code:
import numpy as npy
ar1 = npy.array([1, 2, 3, 4, 5])
filter_ar1 = ar1 % 2 == 0
newar1 = ar1[filter_ar1]
print(filter_ar1)
print(newar1)
a) [false true false true false]
[2 4]
b) [true false true false true]
[1 3 5]
c) [false false false true false]
[4]
d) [true true false false false]
[1 2]
Ans: a) [false true false true false]
[2 4]
255. Random numbers are generated through ______ algorithm
a) random
b) pseudo random
c) true random
d) None of the above
Ans: b) pseudo random
256. Application of random numbers from the following:
a) Digital roulette
b) Encryption keys
c) Both a) and b)
d) None of the above
Ans: c) Both a) and b)
257. ________ method returns random float values between 0 to 1.
a) rand()
b) rand_float()
c) randint()
d) choice()
Ans: a) rand()
258. ________ method returns random int values.
a) rand()
b) rand_float()
c) randint()
d) choice()
Ans: c) randint()
259. Statement 1: choice() function generates a random value based on array values
Statement 2: choice() function takes array as parameter and randomly returns one of the values.
a) Statement 1 is true Statement 2 is false
b) Statement 2 is true Statement 1 is false
c) Statement 1 is false Statement 2 is false
d) Statement 1 is true Statement 2 is true
Ans: d) Statement 1 is true Statement 2 is true
260. _________ is known as the list of all possible values and how each occurs.
a) Data distribution
b) Random distribution
c) Probability density function
d) None of the above
Ans: a) Data distribution
261. Function which describes continuous probability of all values in an array is:
a) Data distribution
b) Random distribution
c) Probability density function
d) None of the above
Ans: c) Probability density function
262. The sum of all probability numbers should be ___.
a) 0
b) 1
c) 100
d) None of the above
Ans: b) 1
263. ________ means changing arrangement of elements in place.
a) Shuffle
b) Permutation
c) Seaborn
d) None of the above
Ans: a) Shuffle
264. _______ means arrangement of elements.
a) Shuffle
b) Permutation
c) Seaborn
d) None of the above
Ans: b) Permutation
265. Statement 1: shuffle() method makes changes to original array
Statement 2: permutation() method makes changes to original array
a) Statement 1 is true and Statement 2 is true
b) Statement 1 is false and Statement 2 is true
c) Statement 1 is false and Statement 2 is false
d) Statement 1 is true and Statement 2 is false
Ans: d) Statement 1 is true and Statement 2 is false
Permutation() method returns rearranged array and doesn’t make changes to the original array
266. Distplot stands for______.
a) Distribute plot
b) Distribution plot
c) Distributed plot
d) None of the above
Ans: b) Distribution plot
267. “Seaborn plot is used to visualize random distribution”, state whether true or false.
a) True
b) False
Ans: a) True
268. Normal distribution is also known as _____ distribution.
a) Caussian
b) Bell Curve
c) Gaussian
d) both b) and c)
Ans: d) both b) and c)
269. Binomial Distribution is also known as ________ distribution.
a) Caussian
b) Gaussian
c) Discrete
d) Bell Curve
Ans: c) Discrete
270. The parameters for Binomial Distribution:
a) n
b) p
c) size
d) All of the above
Ans: d) All of the above
271. The parameters for number of trials is:
a) n
b) p
c) size
d) None of the above
Ans: a) n
272. The parameters for probability of occurrence is:
a) n
b) p
c) size
d) None of the above
Ans: b) p
273. The parameters for the shape of the returned array is:
a) n
b) p
c) size
d) None of the above
Ans: c) size
274. Guess the output of the code:
from numpy import random
x = random.binomial(n=10, p=0.5, size=10)
print(x)
a) [4 4 6 4 4 2 5 4 6 2]
b) [5 7 6 7 2 7 6 5 5 3]
c) [7 4 6 3 4 6 3 6 7 4]
d) All of the above
Ans: d) All of the above, as random variable generates random values upto 10 excluding 10.
275. Poisson Distribution is also known as ________ distribution.
a) Caussian
b) Gaussian
c) Discrete
d) Bell Curve
Ans: c) Discrete
276. ______ parameter is known for number of occurrences.
a) lam
b) n
c) size
d) p
Ans: a) lam
277. ______ parameter is known for the shape of the returned array.
a) lam
b) n
c) size
d) p
Ans: c) size
278. Difference between normal and poisson distribution
a) normal is continuous and poisson is discrete
b) normal has 2 outcomes, and poisson have unlimited outcomes
c) both a) and b)
d) None of the above
Ans: a) normal is continuous and poisson is discrete
279. Difference between binomial and poisson distribution
a) binomial is continuous and poisson is discrete
b) binomial has 2 outcomes, and poisson have unlimited outcomes
c) both a) and b)
d) None of the above
Ans: b) binomial has 2 outcomes, and poisson have unlimited outcomes
280. ________ distribution is used to describe probability where every event has equal chances of occurring.
a) Normal Distribution
b) Poisson Distribution
c) Uniform Distribution
d) Logistic Distribution
Ans: c) Uniform Distribution
281. _______ distribution is used to describe growth.
a) Normal Distribution
b) Poisson Distribution
c) Uniform Distribution
d) Logistic Distribution
Ans: d) Logistic Distribution
282. _____ parameter is used for lower bound.
a) a
b) b
c) size
d) None of these
Ans: a) a
283. _____ parameter is used for upper bound.
a) a
b) b
c) size
d) None of these
Ans: b) b
284. ______ parameter is used for mean where the peak is in logistic distribution.
a) loc
b) scale
c) size
d) None of these
Ans: a) loc
285. ______ parameter is used for standard deviation, that is, flatness of distribution is in logistic distribution.
a) loc
b) scale
c) size
d) None of these
Ans: b) scale
286. Multinomial distribution is generalization of _________ distribution.
a) Normal Distribution
b) Poisson Distribution
c) Binomial Distribution
d) Logistic Distribution
Ans: c) Binomial Distribution
287. _____ parameters number of possible outcomes.
a) n
b) a
c) pvals
d) size
Ans: a) n
288. _____ parameters list of probabilities of outcomes.
a) n
b) a
c) pvals
d) size
Ans: c) pvals
289. _______ used for balancing time for next event.
a) Normal Distribution
b) Poisson Distribution
c) Binomial Distribution
d) Exponential Distribution
Ans: d) Exponential Distribution
290. _______ parameter is used for inverse of rate default in exponential distribution.
a) scale
b) n
c) a
d) pvals
Ans: a) scale
291. Statement 1: “Poisson distribution deals with number of occurrences of an event in a time period”
Statement 2: “Exponential distribution deals with the time between these events”
a) Statement 1 is true and Statement 2 is false
b) Statement 1 is false and Statement 2 is true
c) Statement 1 is true and Statement 2 is true
d) Statement 1 is false and Statement 2 is false
Ans: c) Statement 1 is true and Statement 2 is true
292. ________ distribution is used for verify hypothesis.
a) Binomial
b) Multimonial
c) Exponential
d) Chi square
Ans: d) Chi square
293. ____ parameter degree of freedom.
a) df
b) a
c) n
d) b
Ans: a) df
294. _________ distribution used in signal processing.
a) Rayleigh
b) Multimonial
c) Exponential
d) Chi square
Ans: a) Rayleigh
295. _________ distribution following 80-20 rule.
a) Rayleigh
b) Pareto
c) Exponential
d) Chi square
Ans: b) Pareto
296. Converting iterative statements into vector based operation is called ________.
a) initialization
b) conversion
c) iteration
d) vectorization
Ans: d) vectorization
297. ________ argument is used to output array when return value should be copied.
a) where
b) dtype
c) out
d) ndarray
Ans: c) out
298. ufuncs stands for _________
a) Universe functions
b) Universed function
c) Universal function
d) Universal functions
Ans: d) Universal functions
CHAPTER 21: PYTHON MODULES – PANDAS
299. Pandas in Python refer to _____
a) Panel data
b) Python Data Analysis
c) both a) and b)
d) None of these
Ans: c) both a) and b)
300. The function of Pandas are:
a) analyzing
b) cleaning
c) exploring
d) All the above
Ans: d) All the above
301. Guess the output of the code:
import pandas as pd
dataset = {
‘brands’: [“Westside”, “Valentino”, “Fenty”],
‘passings’: [3, 7, 2]
}
var1 = pd.Dataframe(dataset)
print(var1)
a) brands passings
0 Westside 3
1 Valentino 7
2 Fenty 2
b) brands passings
0 Westside 3
1 Valentino 7
c) Error message
d) None of these
Ans: a) brands passings
0 Westside 3
1 Valentino 7
2 Fenty 2
302. _______ is like one dimensional array holding data of any type
a) Panda arrays
b) Panda columns
c) Pandas series
d) Panda associates
Ans: c) Pandas series
303. Multidimensional tables which are data sets in Panda are called as_______.
a) DataFrames
b) DataSets
c) DataValues
d) DataTables
Ans: a) DataFrames
304. Guess the output of the following code:
import pandas as pd
data = {
“packages”: [233, 345, 456]
“quantities”: [4, 3, 7]
}
var1 = pd. DataFrame(data)
print(var1)
a) brands passings
0 Westside 3
1 Valentino 7
2 Fenty 2
b) brands passings
0 Westside 3
1 Valentino 7
c) brands passings
0 Westside 3
d) Error message
Ans: a) brands passings
0 Westside 3
1 Valentino 7
2 Fenty 2
305. Pandas use the ______ attribute to return one or more specified rows
a) return
b) sort
c) loc
d) panda_return
Ans: c) loc
306. CSV files are known as _____
a) compiled short version
b) compiled short files
c) comma short files
d) comma separated files
Ans: d) comma separated files
307. ________ is used to print the entire DataFrame.
a) to_print()
b) to_string()
c) to_data()
d) to_frame()
Ans: b) to_string()
308. To check the system’s maximum rows we use ______ statement.
a) max_rows()
b) display.max_rows()
c) display.max_rows
d) pd.options.display.max_rows
Ans: d) pd.options.display.max_rows
309. Big data sets are often stored and retrieved as ____.
a) CSV
b) TXT
c) JSON
d) None of the above
Ans: c) JSON
310. Guess the output of the following code:
import pandas as pd
data = {
“Quantities”:{
“0”: 100
“1”: 52
“2”: 667
“3”: 68
}
“Prices”:{
“0”: 234
“1”: 435
“2”: 567
“3”: 789
}
}
df = pd.DataFrame(data)
print(df)
a) Quantities Prices
0 10 234
1 52 435
2 667 567
3 68 789
b) Quantities Prices
0 10 234
1 52 435
2 667 567
c) Quantities Prices
0 10 234
1 52 435
d) None of these
Ans: a) Quantities Prices
0 10 234
1 52 435
2 667 567
3 68 789
311. Guess the output of the following code:
import pandas as pds
data = {
“Veg_items”:{
“0”: 123
“1”: 59
“2”: 67
“3”: 18
}
“Prices”:{
“0”: 123
“1”: 45
“2”: 56
“3”: 79
}
}
df = pd.DataFrame(data)
print(df)
a) Veg_items Prices
0 123 123
1 59 45
2 67 56
3 18 79
b) Veg_items Prices
0 123 123
1 59 45
2 67 56
c) Veg_items Prices
0 123 123
1 59 45
d) None of these
Ans: a) Veg_items Prices
0 123 123
1 59 45
2 67 56
3 18 79
312. _________ method returns from the top headers and specified number of rows.
a) head()
b) tail()
c) info()
d) None of these
Ans:
313. _________ method returns from the bottom headers and specified number of rows.
a) head()
b) tail()
c) info()
d) None of these
Ans: b) tail()
314. _________ method gives information of dataset.
a) head()
b) tail()
c) info()
d) None of these
Ans: c) info()
315. ________ means fixing erroneous data in dataset.
a) Data cleaning
b) Data mining
c) Data warehouse
d) All of the above
Ans: a) Data cleaning
316. The things which comes under erroneous data is:
a) empty cells
b) wrong data and data in wrong format
c) duplicates
d) All of the above
Ans: d) All of the above
317. ______ method replaces empty cells with a value.
a) fillna()
b) fill()
c) dropna()
d) drop()
Ans: a) fillna()
318. _________ is the average value.
a) mean
b) median
c) mode
d) None of the above
Ans: a) mean
319. _________ is the value in the middle.
a) mean
b) median
c) mode
d) None of the above
Ans: b) median
320. _________ is the value that appears more frequently.
a) mean
b) median
c) mode
d) None of the above
Ans: c) mode
321. ________ method is used for removing the row.
a) fillna()
b) fill()
c) dropna()
d) drop()
Ans: c) dropna()
322. The method which returns boolean values for each row:
a) duplicates()
b) bool_value()
c) duplicate_value()
d) duplicated()
Ans: d) duplicated()
323. _________ method calculates the relationship between each data set.
a) cor()
b) corr()
c) compare()
d) compares()
Ans: b) corr()
324. “corr() ignores non- numeric values”, state whether it’s true of false.
a) True
b) False
Ans: a) True
CHAPTER 22: PYTHON MODULE REFERENCE
325. ________ method is used to initialize the random number generator.
a) seed()
b) getstate()
c) setstate()
d) getrandbits()
Ans: a) seed()
326. ________ method is used to return the current internal state of random number generator.
a) seed()
b) getstate()
c) setstate()
d) getrandbits()
Ans: b) getstate()
327. ________ method is used to restore the internal state of the random number generator.
a) seed()
b) getstate()
c) setstate()
d) getrandbits()
Ans: c) setstate()
328. ________ method is used to return the number representing a random bit.
a) seed()
b) getstate()
c) setstate
d) getrandbits()
Ans: d) getrandbits()
329. ________ method is used to return the random number between the given range.
a) randrange()
b) randint()
c) choice()
d) choices()
Ans: a) randrange()
330. ________ method is used to return the random number between the given range.
a) randrange()
b) randint()
c) choice()
d) choices()
Ans: b) randint()
331. ________ method is used to return the random element from the given sequence.
a) randrange()
b) randint()
c) choice()
d) choices()
Ans: c) choice()
332. ________ method is used to return the list with a random selection from the given sequence.
a) randrange()
b) randint()
c) choice()
d) choices()
Ans: d) choices()
333. _______ method takes a sequence and returns the sequence in random order.
a) shuffle()
b) sample()
c) random()
d) uniform()
Ans: a) shuffle()
334. _______ method returns a given sample of a sequence.
a) shuffle()
b) sample()
c) random()
d) uniform()
Ans: b) sample()
335. _______ method returns a random float number between 0 and 1.
a) shuffle()
b) sample()
c) random()
d) uniform()
Ans: c) random()
336. _______ method returns a random float number between two given parameters.
a) shuffle()
b) sample()
c) random()
d) uniform()
Ans: d) uniform()
337. ________ returns a random float number between two given parameters, and sets a mode parameter to specify the midpoint between the other two parameters.
a) triangular()
b) betavariate()
c) expovariate()
d) gammavariate()
Ans: a) triangular()
338. ________ returns a random float number between 0 and 1 based on the Beta distribution.
a) triangular()
b) betavariate()
c) expovariate()
d) gammavariate()
Ans: b) betavariate()
339. ________ returns a random float number based on the Exponential distribution.
a) triangular()
b) betavariate()
c) expovariate()
d) gammavariate()
Ans: c) expovariate()
340. ________ returns a random float number based on Gamma distribution.
a) triangular()
b) betavariate()
c) expovariate()
d) gammavariate()
Ans: d) gammavariate()
341. __________ returns a random float number based on the Gaussian distribution.
a) gauss()
b) lognormvariate()
c) normalvariate()
d) vonmisesvariate()
Ans: a) gauss()
342. __________ returns a random float number based on the log-normal distribution.
a) gauss()
b) lognormvariate()
c) normalvariate()
d) vonmisesvariate()
Ans: b) lognormvariate()
343. __________ returns a random float number based on the normal distribution.
a) gauss()
b) lognormvariate()
c) normalvariate()
d) vonmisesvariate()
Ans: c) normalvariate()
344. __________ returns a random float number based on the von Mises distribution.
a) gauss()
b) lognormvariate()
c) normalvariate()
d) vonmisesvariate()
Ans: d) vonmisesvariate()
345. __________ returns a random float number based on the Pareto distribution.
a) gauss()
b) lognormvariate()
c) paretovariate()
d) weibullvariate()
Ans: c) paretovariate()
346. __________ returns a random float number based on the Weibull distribution.
a) gauss()
b) lognormvariate()
c) paretovariate()
d) weibullvariate()
Ans: d) weibullvariate()
347. _________ module allows to send HTTP requests using Python.
a) requests
b) random
c) statistics
d) cMath
Ans: a) requests
348. ________(parameters), method with parameters, sends a delete request to the specified url.
a) delete (url, args)
b) delete (url, params, args)
c) delete (url, data, args)
d) delete (url, data, json, args)
Ans: a) delete (url, args)
349. ________(parameters), method with parameters, sends a get request to the specified url.
a) get (url, args)
b) get (url, params, args)
c) get (url, data, args)
d) get (url, data, json, args)
Ans: b) get (url, params, args)
350. ________(parameters), method with parameters, sends a head request to the specified url.
a) head (url, args)
b) head (url, params, args)
c) head (url, data, args)
d) head (url, data, json, args)
Ans: a) head (url, args)
351. ________(parameters), method with parameters, sends a patch request to the specified url.
a) patch (url, args)
b) patch (url, params, args)
c) patch (url, data, args)
d) patch (url, data, json, args)
Ans: c) patch (url, data, args)
352. ________(parameters), method with parameters, sends a post request to the specified url.
a) post (url, args)
b) post (url, params, args)
c) post (url, data, args)
d) post (url, data, json, args)
Ans: d) post (url, data, json, args)
353. ________(parameters), method with parameters, sends a put request to the specified url.
a) put (url, args)
b) put (url, params, args)
c) put (url, data, args)
d) put (url, data, json, args)
Ans:
354. ________(parameters), method with parameters, sends a request to the specified method to the specified url.
a) request (method, url, args)
b) request (url, params, args)
c) request (url, data, args)
d) request (url, data, json, args)
Ans: a) request (method, url, args)
355. ________ methods calculates the central location of the given data.
a) statistics.harmonic_mean()
b) statistics.mean()
c) statistics.median()
d) statistics.median_grouped()
Ans: a) statistics.harmonic_mean()
356. ________ methods calculates the average of the given data.
a) statistics.harmonic_mean()
b) statistics.mean()
c) statistics.median()
d) statistics.median_grouped()
Ans: b) statistics.mean()
357. ________ methods calculates the middle value of the given data.
a) statistics.harmonic_mean()
b) statistics.mean()
c) statistics.median()
d) statistics.median_grouped()
Ans: c) statistics.median()
358. ________ methods calculates the median of grouped continuous data.
a) statistics.harmonic_mean()
b) statistics.mean()
c) statistics.median()
d) statistics.median_grouped()
Ans: d) statistics.median_grouped()
359. ________ methods calculates the high median of the given data.
a) statistics.median_high()
b) statistics.median_low()
c) statistics.mode()
d) statistics.pstdev()
Ans: a) statistics.median_high()
360. ________ methods calculates the low median of the given data.
a) statistics.median_high()
b) statistics.median_low()
c) statistics.mode()
d) statistics.pstdev()
Ans: statistics.median_low()
361. ________ methods calculates the central tendency of the given numeric or nominal data.
a) statistics.median_high()
b) statistics.median_low()
c) statistics.mode()
d) statistics.pstdev()
Ans: c) statistics.mode()
362. ________ methods calculates the standard deviation from an entire population.
a) statistics.median_high()
b) statistics.median_low()
c) statistics.mode()
d) statistics.pstdev()
Ans: d) statistics.pstdev()
363. ________ method calculates the standard deviation from an entire population.
a) statistics.pstdev()
b) statistics.stdev()
c) statistics.pvariance()
d) statistics.variance()
Ans: b) statistics.stdev()
364. __________ method calculates the variance of an entire population.
a) statistics.pstdev()
b) statistics.stdev()
c) statistics.pvariance()
d) statistics.variance()
Ans: c) statistics.pvariance()
365. __________ method calculates the variance from a sample of data.
a) statistics.pstdev()
b) statistics.stdev()
c) statistics.pvariance()
d) statistics.variance()
Ans: d) statistics.variance()
366. ________ module returns the arc cosine of a number.
a) math.acos()
b) math.acosh()
c) math.asin()
d) math.asinh()
Ans: a) math.acos()
367. ________ module returns the inverse of hyperbolic cosine of a number.
a) math.acos()
b) math.acosh()
c) math.asin()
d) math.asinh()
Ans: b) math.acosh()
368. ________ module returns the arc sine of a number.
a) math.acos()
b) math.acosh()
c) math.asin()
d) math.asinh()
Ans: c) math.asin()
369. ________ module returns the inverse hyperbolic sine of a number.
a) math.acos()
b) math.acosh()
c) math.asin()
d) math.asinh()
Ans: d) math.asinh()
370. _________ module returns the arc tangent of a number in radians.
a) math.atan()
b) math.atan2()
c) math.atanh()
d) math.ceil()
Ans: a) math.atan()
371. _________ module returns the arc tangent of y/x in radians.
a) math.atan()
b) math.atan2()
c) math.atanh()
d) math.ceil()
Ans: b) math.atan2()
372. _________ module returns inverse hyperbolic tangent of a number.
a) math.atan()
b) math.atan2()
c) math.atanh()
d) math.ceil()
Ans: c) math.atanh()
373. _________ module rounds a number upto the nearest integer.
a) math.atan()
b) math.atan2()
c) math.atanh()
d) math.ceil()
Ans: d) math.ceil()
374. _________ module returns the number of ways to choose k items from n items without repetition and order.
a) math.comb()
b) math.copysign()
c) math.degrees()
d) math.dist()
Ans: a) math.comb()
375. _________ module returns a float consisting of a value of the first parameter and the sign of the second parameter.
a) math.comb()
b) math.copysign()
c) math.degrees()
d) math.dist()
Ans: b) math.copysign()
376. _________ module converts an angle from radians to degrees.
a) math.comb()
b) math.copysign()
c) math.degrees()
d) math.dist()
Ans: c) math.degrees()
378. _________ module returns the Euclidean distance between two points.
a) math.comb()
b) math.copysign()
c) math.degrees()
d) math.dist()
Ans: d) math.dist()
379. _________ module returns the error function of a number.
a) math.erf()
b) math.erfc()
c) math.exp()
d) math.expm1()
Ans: a) math.erf()
380. _________ module returns the complementary error function of a number.
a) math.erf()
b) math.erfc()
c) math.exp()
d) math.expm1()
Ans: b) math.erfc()
381. _________ module returns E raised to the power of x.
a) math.erf()
b) math.erfc()
c) math.exp()
d) math.expm1()
Ans: c) math.exp()
382. _________ method returns Ex-1.
a) math.erf()
b) math.erfc()
c) math.exp()
d) math.expm1()
Ans: d) math.expm1()
383. _________ method returns the absolute value of a number.
a) math.fabs()
b) math.factorial()
c) math.floor()
d) math.fmod()
Ans: a) math.fabs()
384. _________ method returns the factorial of a number.
a) math.fabs()
b) math.factorial()
c) math.floor()
d) math.fmod()
Ans: b) math.factorial()
385. __________ method rounds the number down to nearest integer.
a) math.fabs()
b) math.factorial()
c) math.floor()
d) math.fmod()
Ans: c) math.floor()
386. _________ method returns the remainder x/y.
a) math.fabs()
b) math.factorial()
c) math.floor()
d) math.fmod()
Ans: d) math.fmod()
387. __________ method returns the mantisa and exponent.
a) math.frexp()
b) math.fsum()
c) math.gamma()
d) math.gcd()
Ans: a) math.frexp()
388. _________ method returns the sum of all items in any iterable.
a) math.frexp()
b) math.fsum()
c) math.gamma()
d) math.gcd()
Ans: b) math.fsum()
389. _________ method returns the gamma function at x.
a) math.frexp()
b) math.fsum()
c) math.gamma()
d) math.gcd()
Ans: c) math.gamma()
390. _________ method returns the greatest common divisor of the 2 integers.
a) math.frexp()
b) math.fsum()
c) math.gamma()
d) math.gcd()
Ans: d) math.gcd()
391. __________ method which returns the Euclidean norm.
a) math.hypot()
b) math.isclose()
c) math.isfinite()
d) math.isinf()
Ans: a) math.hypot()
392. _________ method which checks whether the two values are close to each other or not.
a) math.hypot()
b) math.isclose()
c) math.isfinite()
d) math.isinf()
Ans: b) math.isclose()
393. _________ method checks whether a number is finite or not.
a) math.hypot()
b) math.isclose()
c) math.isfinite()
d) math.isinf()
Ans: c) math.isfinite()
394. _________ method checks whether a number is infinite or not.
a) math.hypot()
b) math.isclose()
c) math.isfinite()
d) math.isinf()
Ans: d) math.isinf()
395. _________ method checks whether a value is NaN (not a number) or not.
a) math.isnan()
b) math.isqrt()
c) math.Idexp()
d) math.lgamma()
Ans: a) math.isnan()
396. _________ method rounds a square root number down to an integer.
a) math.isnan()
b) math.isqrt()
c) math.Idexp()
d) math.lgamma()
Ans: b) math.isqrt()
397. _________ method returns the inverse of math.frexp().
a) math.isnan()
b) math.isqrt()
c) math.Idexp()
d) math.lgamma()
Ans: c) math.Idexp()
399. _________ method returns the log gamma value of x.
a) math.isnan()
b) math.isqrt()
c) math.Idexp()
d) math.lgamma()
Ans: d) math.lgamma()
400. _________ method returns natural logarithm of a number.
a) math.log()
b) math.log10()
c) math.log1p()
d) math.log2()
Ans: a) math.log()
401. _________ method returns base-10 logarithm of x.
a) math.log()
b) math.log10()
c) math.log1p()
d) math.log2()
Ans: b) math.log10()
402. _________ method returns natural logarithm of 1+x.
a) math.log()
b) math.log10()
c) math.log1p()
d) math.log2()
Ans: c) math.log1p()
403. _________ method returns base-2 logarithm of x.
a) math.log()
b) math.log10()
c) math.log1p()
d) math.log2()
Ans: d) math.log2()
404. _________ method returns the permutation value without repetition.
a) math.perm()
b) math.pow()
c) math.prod()
d) math.radians()
Ans: a) math.perm()
405. __________ method returns the value of x to the power of y.
a) math.perm()
b) math.pow()
c) math.prod()
d) math.radians()
Ans: b) math.pow()
406. __________ method returns the product of all the elements in an iterable.
a) math.perm()
b) math.pow()
c) math.prod()
d) math.radians()
Ans: c) math.prod()
407. __________ method converts a degree value into radians.
a) math.perm()
b) math.pow()
c) math.prod()
d) math.radians()
Ans: d) math.radians()
408. ________ method returns the remainder value after division.
a) math.remainder()
b) math.sin()
c) math.sinh()
d) math.sqrt()
Ans: a) math.remainder()
409. __________ method returns the sine of a number.
a) math.remainder()
b) math.sin()
c) math.sinh()
d) math.sqrt()
Ans: b) math.sin()
410. __________ method returns the hyperbolic sine of a number.
a) math.remainder()
b) math.sin()
c) math.sinh()
d) math.sqrt()
Ans: c) math.sinh()
411. __________ method returns the square root of a number.
a) math.remainder()
b) math.sin()
c) math.sinh()
d) math.sqrt()
Ans: d) math.sqrt()
412. ___________ method returns the tangent of a number.
a) math.tan()
b) math.tanh()
c) math.trunc()
d) math.tau()
Ans: a) math.tan()
413. ___________ method returns the hyperbolic tangent of a number.
a) math.tan()
b) math.tanh()
c) math.trunc()
d) math.tau()
Ans: b) math.tanh()
414. ____________ method truncates the integer part of a number.
a) math.tan()
b) math.tanh()
c) math.trunc()
d) math.tau()
Ans: c) math.trunc()
415. ____________ method returns the value of tau = 6. 2831…
a) math.tan()
b) math.tanh()
c) math.trunc()
d) math.tau()
Ans: d) math.tau()
416. _________ module has a set of constants and methods.
a) cmath
b) math
c) random
d) request
Ans: a) cmath
417. _______ methods return the arc cosine value of x.
a) cmath.acos(x)
b) cmath.acosh(x)
c) cmath.asin(x)
d) cmath.asinh(x)
Ans: a) cmath.acos(x)
418. _______ methods return the hyperbolic arc cosine value of x.
a) cmath.acos(x)
b) cmath.acosh(x)
c) cmath.asin(x)
d) cmath.asinh(x)
Ans: b) cmath.acosh(x)
419. _______ methods return the arc sine value of x.
a) cmath.acos(x)
b) cmath.acosh(x)
c) cmath.asin(x)
d) cmath.asinh(x)
Ans: c) cmath.asin(x)
420. ________ methods return the hyperbolic arc sine value of x.
a) cmath.acos(x)
b) cmath.acosh(x)
c) cmath.asin(x)
d) cmath.asinh(x)
Ans: d) cmath.asinh(x)
421. ________ methods return the arc tangent value of x.
a) cmath.atan(x)
b) cmath.atanh(x)
c) cmath.acos(x)
d) cmath.acosh(x)
Ans: a) cmath.atan(x)
422. ________ methods return hyperbolic arc tangent value of x.
a) cmath.atan(x)
b) cmath.atanh(x)
c) cmath.acos(x)
d) cmath.acosh(x)
Ans: b) cmath.atanh(x)
423. ________ methods return the arc cosine value of x.
a) cmath.atan(x)
b) cmath.atanh(x)
c) cmath.acos(x)
d) cmath.acosh(x)
Ans: c) cmath.acos(x)
424. ________ methods return hyperbolic cosine value of x.
a) cmath.atan(x)
b) cmath.atanh(x)
c) cmath.acos(x)
d) cmath.acosh(x)
Ans: d) cmath.acosh(x)
425. ________ method returns the value of Ex.
a) cmath.exp(x)
b) cmath.isclose()
c) cmath.isfinite()
d) cmath.isinf()
Ans: a) cmath.exp(x)
426. _________ method checks whether two values are close.
a) cmath.exp(x)
b) cmath.isclose()
c) cmath.isfinite()
d) cmath.isinf()
Ans: b) cmath.isclose()
427. _________ method checks whether x is finite number.
a) cmath.exp(x)
b) cmath.isclose()
c) cmath.isfinite()
d) cmath.isinf()
Ans: c) cmath.isfinite()
428. _________ method check whether x is positive or negative infinity.
a) cmath.exp(x)
b) cmath.isclose()
c) cmath.isfinite()
d) cmath.isinf()
Ans: d) cmath.isinf()
429. __________ method returns the phase of a complex number.
a) cmath.phase()
b) cmath.polar()
c) cmath.rect()
d) cmath.sin()
Ans: a) cmath.phase()
430. __________ method converts a complex number to polar coordinates.
a) cmath.phase()
b) cmath.polar()
c) cmath.rect()
d) cmath.sin()
Ans: b) cmath.polar()
431. ___________ method converts polar coordinates to rectangular form.
a) cmath.phase()
b) cmath.polar()
c) cmath.rect()
d) cmath.sin()
Ans: c) cmath.rect()
432. ____________ method returns the sine x.
a) cmath.phase()
b) cmath.polar()
c) cmath.rect()
d) cmath.sin()
Ans: d) cmath.sin()
CHAPTER 23: PYTHON MATPLOTLIB
433. _________ is used as a visualization tool in Python.
a) NumPy
b) Pandas
c) Matplotlib
d) Matplot
Ans: c) Matplotlib
434. The version string is stored is ________ attribute
a) string
b) __version__
c) version
d) __string__
Ans: b) __version__
435. ______ function is used to draw points (marker) in a diagram.
a) plot()
b) marker()
c) function()
d) show()
Ans: a) plot()
436. _________ keyword argument to emphasize each point with a specified marker.
a) plot
b) star
c) marker
d) point
Ans: c) marker
437. ____ marker description – circle in matplotlib.
a) o
b) *
c) .
d) ,
Ans: a) o
438. ____ marker description – star in matplotlib.
a) o
b) *
c) .
d) ,
Ans: b) *
439. ____ marker description – point in matplotlib.
a) o
b) *
c) .
d) ,
Ans: c) .
440. ____ marker description – pixel in matplotlib.
a) o
b) *
c) .
d) ,
Ans: d) ,
441. ____ marker description – x in matplotlib.
a) x
b) +
c) P
d) s
Ans: a) x
442. ____ marker description – plus in matplotlib.
a) x
b) +
c) P
d) s
Ans: b) +
443. ____ marker description – plus (filled) in matplotlib.
a) x
b) +
c) P
d) s
Ans: c) P
444. ____ marker description – square in matplotlib.
a) x
b) +
c) P
d) s
Ans: d) s
445. ____ marker description – diamond in matplotlib.
a) D
b) d
c) p
d) H
Ans: a) D
446. ____ marker description – diamond (thin) in matplotlib.
a) D
b) d
c) p
d) H
Ans: b) d
447. ____ marker description – pentagon in matplotlib.
a) D
b) d
c) p
d) H
Ans: c) p
448. ____ marker description – hexagon in matplotlib.
a) D
b) d
c) p
d) H
Ans: d) H
449. ____ marker description – triangle down in matplotlib.
a) v
b) ^
c) <
d) >
Ans: a) v
450. ____ marker description – triangle up in matplotlib.
a) v
b) ^
c) <
d) >
Ans: b) ^
451. ____ marker description – triangle left in matplotlib.
a) v
b) ^
c) <
d) >
Ans: c) <
452. ____ marker description – triangle right in matplotlib.
a) v
b) ^
c) <
d) >
Ans: d) >
453. ____ marker description – tri up in matplotlib.
a) 1
b) 2
c) 3
d) 4
Ans: a) 1
454. ____ marker description – tri down in matplotlib.
a) 1
b) 2
c) 3
d) 4
Ans: b) 2
455. ____ marker description – tri left in matplotlib.
a) 1
b) 2
c) 3
d) 4
Ans: c) 3
456. ____ marker description – tri right in matplotlib.
a) 1
b) 2
c) 3
d) 4
Ans: d) 4
457. ____ marker description – vline in matplotlib.
a) .
b) !
c) |
d) –
Ans: c) |
458. ____ marker description – hline in matplotlib.
a) .
b) !
c) |
d) –
Ans: d) –
459. _____ is line syntax description- solid line
a) –
b) :
c) —
d) -.
Ans: a) –
460. _____ is line syntax description- dotted line
a) –
b) :
c) —
d) -.
Ans: b) :
461. _____ is line syntax description- dashed line
a) –
b) :
c) —
d) -.
Ans: c) –
462. _____ is line syntax description- dashed/dotted line
a) –
b) :
c) —
d) -.
Ans: d) -.
463. _____ functions to set a label for x-axis
a) xlabel()
b) ylabel()
c) title()
d) None of these
Ans: a) xlabel()
464. _____ functions to set a label for y-axis
a) xlabel()
b) ylabel()
c) title()
d) None of these
Ans: b) ylabel()
465. ______ functions to set a title for plot
a) xlabel()
b) ylabel()
c) title()
d) None of these
Ans: c) title()
466. ________ function can draw multiple plots in one figure.
a) multipleplot()
b) plot()
c) figure()
d) subplot()
Ans: d) subplot()
467. _________ function to add a legend in matplotlib.
a) legend()
b) plot()
c) grid()
d) marker()
Ans: a) legend()
468. _________ function to add grids in matplotlib
a) legend()
b) plot()
c) grid()
d) marker()
Ans: c) grid()
469. Parameters of plot() function are:
a) marker
b) colour
c) linestyle
d) all of the above
Ans: d) all of the above
470. The alphabet which represents black is:
a) k
b) m
c) b
d) c
Ans: a) k
471. The alphabet which represents magenta is:
a) k
b) m
c) b
d) c
Ans: b) m
472. The alphabet which represents blue is:
a) k
b) m
c) b
d) c
Ans: c) b
473. The alphabet which represents cyan is:
a) k
b) m
c) b
d) c
Ans: d) c
474. The person who created Matplotlib is:
a) John D Hunter
b) Dennis Ritchie
c) Pearu Peterson
d) Robert Kern
Ans: a) John D Hunter
475. “Matplotlib is open- source and free” state whether true and false.
a) True
b) False
Ans: a) True
476. Matplotlib is designed to be as efficient as _____.
a) SciPy
b) Artificial Intelligence
c) MATLAB
d) All of the above
Ans: c) MATLAB
477. Matplotlib is a _____ library for Python.
a) data science
b) mathematics
c) numpy
d) plotting
Ans: d) plotting
478. The correct command to install Matplotlib is:
a) pip install matplotlib
b) pip.install.matplotlib
c) pip install Matplotlib
d) Pip install Matplotlib
Ans: a) pip install matplotlib, this command is given after installation of Python and PIP
479. _______ is a module that provides MATLAB-like interface.
a) function
b) collection
c) class
d) module
Ans: d) module
480. Function used to create a box plot in Matplotlib is:
a) plt.boxplot()
b) plt_boxplot()
c) plt.plotbox()
d) plt_plotbox()
Ans: a) plt.boxplot()
481. Default type of histogram in Matplotlib is:
a) Line
b) Dotted lines
c) Bar
d) Dashed lines
Ans: c) Bar
482. Graphical representation of data is:
a) Data Plotting
b) Data Handling
c) Data Analysis
d) Data Visualization
Ans: d) Data Visualization
483. Default color of plot in Matplotlib is:
a) Black
b) Blue
c) Red
d) Orange
Ans: b) Blue
484. Function used to save an image file in Python is:
a) savefig()
b) saveimage()
c) saveimg()
d) savefigure()
Ans: a) savefig()
485. Box plot is also known as:
a) Histogram
b) Whisker plot
c) Bar
d) Dotted line
Ans: b) Whisker plot
486. Function to activate a style is:
a) plt.style.available()
b) plt.style.use()
c) plot.style.available()
d) plot.style.use()
Ans: b) plt.style.use()
487. Function to create histogram is:
a) histogram()
b) histo()
c) histograms()
d) hist()
Ans: d) hist()
488. Function to create bar is:
a) create_bar()
b) bar()
c) create.bar()
d) bars()
Ans: b) bar()
489. Function to create scatter plot is:
a) scatterplot()
b) scatters()
c) scatter()
d) scatterplots()
Ans: c) scatter()
490. Function used to draw multiple figures in one plots:
a) supplot()
b) subplot()
c) supplots()
d) subplots()
Ans: b) subplot()
491. fontdict parameter uses which of the following functions:
a) xlabel()
b) ylabel()
c) title()
d) All of the above
Ans: d) All of the above
492. Parameter used to set font properties for the plot is:
a) fonts
b) fontdict
c) fontfamily
d) fontplot
Ans: b) fontdict
493. _____ parameter sets alignment for title.
a) pos
b) left
c) loc
d) align
Ans: c) loc
494. Parameters used in grid function for line properties
a) color
b) linestyle
c) linewidth
d) All of the above
Ans: d) All of the above
CHAPTER 23: PYTHON SEABORN
495. ________ is used for statistical graph in Python.
a) Pandas
b) NumPy
c) SciPy
d) Seaborn
Ans: d) Seaborn
Seaborn purpose is to create statistical graphs, providing high-level of interface, built on Matplotlib.
496. Function used to create point plot is:
a) sns.pointplot()
b) sns.lineplot()
c) sns.countplot()
d) sns.barplot()
Ans: a) sns.pointplot()
Uses a point chart to visualize relationship between two variables in data set.
497. Function used to create line plot is:
a) sns.pointplot()
b) sns.lineplot()
c) sns.countplot()
d) sns.barplot()
Ans: b) sns.lineplot()
Uses line chart to visualize relationship between two variables in data set.
498. Function used to create count plot is:
a) sns.pointplot()
b) sns.lineplot()
c) sns.countplot()
d) sns.barplot()
Ans: c) sns.countplot()
Uses a Bar chart to visualize a relationship between categorical variables in the data set.
499. Function used to create bar plot is:
a) sns.pointplot()
b) sns.lineplot()
c) sns.countplot()
d) sns.barplot()
Ans: d) sns.barplot()
Uses a Bar chart to visualize a relationship between categorical variable and numeric variable in the dataset.
500. Function used to create heatmap is:
a) sns.pointplot()
b) sns.lineplot()
c) sns.heatmap()
d) sns.barplot()
Ans: c) sns.heatmap()
Colour coded matrix to visualize the relationship between multiple variables