What is the correct way to assign the value 10 to a variable x?
x = 10
What keyword starts a function in Python?
def
What keyword is used to include a Python package in your script?
import
How do you check the first 5 rows of a DataFrame df?
df.head()
What does + do when used with numbers?
Adds them
What type of variable is this: name = "Alice"?
str or string
How do you write an if statement that checks if x is greater than 5?
if x > 5:
Which package is commonly used for data analysis?
pandas
What does * do when used with strings? ("a" * 3)
Repeats string: "aaa"
What will this output: x = 5; y = x; x = 10; print(y)?
5
What does this loop print? for i in range(3): print(i)
0 1 2
What function loads a CSV in pandas?
pd.read_csv()
How to get the average of a column named score in a DataFrame?
df['score'].mean()
What’s the result of 5 // 2?
2 (floor division)
What's the difference between = and ==?
= assigns, == compares
What’s the result of this: len([i for i in range(5) if i%2==0])?
3
How do you import just the sqrt function from the math module?
from math import sqrt
How to filter rows where age > 18 in a DataFrame?
df[df['age'] > 18]
What operator is used to check equality?
==
What will this return: type(3.14)?
<class 'float'>
Write a function that takes two numbers and returns the larger one.
def max(a,b): return a if a>b else b
What does import random allow you to do?
Use functions like random.randint()
What does df.groupby('class').mean() do?
Averages numeric columns by class
What is the output: not (True and False)?
True