1/61
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
The np.arange(5) function creates an array with values [0,1,2,3,4].
True
The loc function in Pandas selects rows and columns using integer-based indexing.
False
The pd.merge() function can perform inner, left, right, and outer joins
True
The plt.plot() function can be used to create both line and scatter plots.
True
In Python, lists are mutable, meaning they can be modified after creation
True
The append() method in Pandas permanently changes the DataFrame unless reassigned.
False
In NumPy, axis=0 usually refers to operations across rows.
True
The startswith() string method checks if a string begins with a specified substring
True
Using in with a list checks whether an element exists in that lost
True
The dropna() function in Pandas removes rows or columns with missing values
True
Which of the following creates a NumPy array of zeros with shape (2,3)?
np.zeros((2,3))
Which join returns only the rows with matching keys in both DataFrames?
Inner join
What does df.head(3) return?
First 3 rows of the DataFrame
Which of the following is correct about NumPy broadcasting?
It allows operations on arrays of different but compatible shapes.
Which Pandas method removes duplicate rows?
df.drop_duplicates()
Which function is used to calculate the square root in Python?
math.sqrt()
np.sqrt()
What is the default axis for df.sum() in Pandas?
axis=0 (column-wise)
Which code correctly selects the first two columns of a NumPy array arr?
arr[:,:2]
Which of the following creates a dictionary in Python?
{“A”:1, “B”:2}
What does df[‘Age’].mean() compute?
The average of the Age column
Which of the following closes a Matplotlib figure?
plt.close()
Which keyword is used to define a function in Python?
def
Which function returns the length of a list mylist?
len(mylist)
What does the following code return?:
“Hello World”.lower()
“hello world”
Which Pandas method displays basic statistics like mean, std, and count?
df.describe()
Applying np.sort(x, axis=0) to a 2D array sorts each row independently
False
In Matplotlib, calling plt.show() clears the current figure from memory.
True
Using plt.subplot(2,2,5) will raise an error.
True
The default x-values in plt.plot([2,4,6]) will be [0,1,2]
True
plt.plot() can only plot a single line at a time
False
We have to use random.seed(42) ensures the random numbers generated can be replicated.
True
pow(x,y) and x ** y return the same result in Python
True
The math module is automatically available in Python
False
Which parameter in plt.savefig() controls image resolution?
dpi
Which statement about np.reshape() is correct?
Cannot reshape in place
Suppose x = nparange(12).reshape(3,4). What does x[:, ::-1] do?
Reverses columns.
Which is the correct way to make a logarithmic x-axis in Matplotlib?
plt.xscale(“log”)
Which of the following is not valid in plt.hist()?
bins = “category”
If plt.subplot(2,2,1) is followed by plt.subplot(2,2,1) again, what happens?
The previous subplot is overwritten.
Which parameter in plt.savefig() can be used to reduce white space around the figure?
bbox_inches = ‘tight’
How to create a 3×3 array with random integers from 0-9?
np.random.randint(10, size(3,3))
If a file is opened with open(‘data.txt’, ‘a’), what happens if the file doesn’t exist?
A new file is created.
Suppose x=np.arange(12).reshape(3,4). What is the result of x[x>5]?
A 1D array
Which Python function is used to determine the data type of a variable?
type()
What is the output of the following code?:
print(f“{1234,5678:.2f}”)
1234.57
Which of the following is NOT a valid keyword for controlling loops in Python?
stop
Given fruits = {“apple”, “banana”, “cherry”}, what is the correct way to access banana?
fruits[1]
Which of the following will correctly reverse a list mylist?
mylist[::-1]
In Python OOP, which method is called automatically when an object is created?
__init__
What happens if you run:
for i in range(3):
for j in range(3):
if i == j:
break
print(i,j)
Only prints when i > j
Given:
x=”Data”
y=”Science”
print(x+y*2)
What is the output?
DataScienceScience
Which of the following is NOT valid dictionary creation?
dict(1=”a”, 2=”b”)
Which string method would you use to check if a string starts with a particular prefix?
.startswith()
What is the result of:
a=[1,2,3]
b = a
b.append(4)
print(a)
[1,2,3,4]
What is the main advantage of using a tuple over a list?
Tuples are faster and use less memory.
A lambda function in Python can take multiple arguments and contain multiple expressions.
False
The elseif keyword can be used for conditional statements.
False
Tuples in Python allow duplicate values.
True
A list is mutable, whereas a tuple and a set are not.
True
Inherited functions can be modified in subclasses.
True
The statement mylist = [1, 2, 3] * 3 creates the list [1, 2, 3, 1, 2, 3, 1, 2, 3].
True
In a for loop using range(start, end), the end value is inclusive.
True