Variables
Logic
Packages
Data Analysis
Operators
100

What is the correct way to assign the value 10 to a variable x?

x = 10

100

What keyword starts a function in Python?

def

100

What keyword is used to include a Python package in your script?

import

100

How do you check the first 5 rows of a DataFrame df?

df.head()

100

What does + do when used with numbers?

Adds them

200

What type of variable is this: name = "Alice"?

str or string

200

How do you write an if statement that checks if x is greater than 5?

if x > 5:

200

Which package is commonly used for data analysis?

pandas

200

What pandas function shows column data types?

df.dtypes or df.info()

200

What does * do when used with strings? ("a" * 3)

Repeats string: "aaa"

300

What will this output: x = 5; y = x; x = 10; print(y)?

5

300

What does this loop print? for i in range(3): print(i)

0 1 2

300

What function loads a CSV in pandas?

pd.read_csv()

300

How to get the average of a column named score in a DataFrame?

df['score'].mean()

300

What’s the result of 5 // 2?

2 (floor division)

400

What's the difference between = and ==?

= assigns, == compares

400

What’s the result of this: len([i for i in range(5) if i%2==0])?

3

400

How do you import just the sqrt function from the math module?

from math import sqrt

400

How to filter rows where age > 18 in a DataFrame?

df[df['age'] > 18]

400

What operator is used to check equality?

==

500

What will this return: type(3.14)?

<class 'float'>

500

Write a function that takes two numbers and returns the larger one.

def max(a,b): return a if a>b else b

500

What does import random allow you to do?

Use functions like random.randint()

500

What does df.groupby('class').mean() do?

Averages numeric columns by class

500

What is the output: not (True and False)?

True

M
e
n
u