Which of the following reasons best explains why Python is widely used for data analysis?
Think about tools that help with handling data easily.
Python's popularity in data analysis comes from its rich ecosystem of libraries like pandas and NumPy that make data tasks easier and faster.
What is the output of this Python code snippet?
import pandas as pd data = {'Name': ['Anna', 'Bob', 'Cara'], 'Age': [28, 34, 22]} df = pd.DataFrame(data) print(df['Age'].mean())
Calculate the average of the ages: 28, 34, and 22.
The mean of 28, 34, and 22 is (28 + 34 + 22) / 3 = 28.0.
Given the DataFrame below, what is the output after filtering rows where 'Score' is greater than 80?
import pandas as pd data = {'Student': ['John', 'Jane', 'Dave', 'Dana'], 'Score': [75, 82, 90, 60]} df = pd.DataFrame(data) filtered_df = df[df['Score'] > 80] print(filtered_df)
Keep only rows where Score is more than 80.
Only Jane and Dave have scores above 80, so only their rows remain.
What does the following Python code plot?
import matplotlib.pyplot as plt x = [1, 2, 3, 4] y = [10, 20, 25, 30] plt.plot(x, y, marker='o') plt.title('Sales Over Time') plt.xlabel('Quarter') plt.ylabel('Sales (in thousands)') plt.show()
Look at the plot type and markers used.
The code creates a line plot with points marked, showing sales increasing over four quarters.
What error will this code produce when run?
import pandas as pd data = {'A': [1, 2, 3], 'B': [4, 5, 6]} df = pd.DataFrame(data) result = df['C'].sum() print(result)
Check if the column 'C' exists in the DataFrame.
The DataFrame has columns 'A' and 'B' only. Accessing 'C' causes a KeyError.