You have a survey dataset with columns Gender and Satisfaction (scale 1-5). What is the average satisfaction score for each gender?
import pandas as pd data = pd.DataFrame({ 'Gender': ['Male', 'Female', 'Female', 'Male', 'Female'], 'Satisfaction': [4, 5, 3, 2, 4] }) result = data.groupby('Gender')['Satisfaction'].mean()
Use groupby on Gender and then calculate the mean of Satisfaction.
The average satisfaction for females is (5 + 3 + 4) / 3 = 4.0, and for males is (4 + 2) / 2 = 3.0.
A survey question uses a 5-point Likert scale (1=Strongly Disagree to 5=Strongly Agree). The distribution of responses is skewed towards 5. What does this indicate?
Think about what a skew towards 5 means on a 1 to 5 scale.
A skew towards 5 means many respondents selected the highest agreement level, indicating strong agreement.
The code below tries to filter respondents aged 30 or older but raises an error. Identify the cause.
import pandas as pd data = pd.DataFrame({'Age': [25, 30, 35, 40]}) filtered = data[data['Age'] >= 30]
Check how the condition inside the brackets is written.
The condition data['Age' >= 30] is invalid because the comparison is done inside the brackets incorrectly. It should be data['Age'] >= 30.
You want to visualize how satisfaction scores vary across different departments in a survey. Which plot type is best?
Think about showing distribution and comparison across categories.
A box plot effectively shows the spread and central tendency of satisfaction scores for each department, making it ideal for this purpose.
You have a dataset with 1000 invited participants. The survey data contains 750 rows of responses. How do you calculate the response rate?
Response rate is the percentage of invited participants who responded.
Response rate is calculated by dividing the number of responses by the number invited, then multiplying by 100 to get a percentage.