Python basics
Pandas
Matplotlib & seaborn
Python snippets
100

print(7 % 3)

2

100

Which command loads Pandas?
A. import pandas as pd
B. import panda as pd
C. import pd
D. from pandas import *

import pandas as pd

100

Which command displays the plot?
A. plt.open()
B. plt.display()
C. plt.show()
D. plt.start()

plt.show()

100

What is the output of: 

 x = 5; print(x * 2 + 1)

11

200

print(10 > 5 and 2 > 3)

False

200

Which command shows the last 3 rows of a DataFrame?

A. df.tail(3)
B. df.start(3)
C. df.head(3)
D. df.first(3)  

df.tail(3)

200

Which command creates a basic line plot?
A. plt.line()
B. plt.plot()
C. plt.graph()
D. plt.map()

plt.plot()

200

print(4 == 4)

True 

300

What is the output? 

x = 5

x + = 2

print(x)

7

300

How do you select a single column named “Age”?

A. df(Age)
B. df.[Age]
C. df["Age"]
D. Both B and C 

df["Age"]

300

You want to see which columns in your dataset have higher or lower correlation with each other using colors. Which Seaborn function helps you do this?

A. sns.barplot()
B. sns.heatmap()
C. sns.boxplot()
D. sns.scatterplot()

sns.heatmap()

300

What is the output of 

name = "Alex"; 

print("Hello", name)

HelloAlex

400

x = 3

while x > 0:

    print(x)

    x -= 1


A. 3
B. 3 2 1
C. 1 2 3
D. Infinite loop 

3 2 1

400

Which function reads an Excel file? 

A. pd.read_excel()
B. pd.import_excel()
C. pd.read_xlsx()
D. pd.open_excel()

pd.read_excel()

400

What is the purpose of plt.title("Graph Title")?
A. Add color
B. Add a title
C. Add a caption
D. Resize the plot

Add a title

400

What is the output of the string method: 

case = "Contract Law"; 

print(case.lower())

contract law

500

for i in range(2):

 print("Hi")


A. Hi
B. Hi Hi
C. Nothing
D. Error

Hi Hi
500

Which command shows the number of rows and columns in a DataFrame?

A. df.size
B. df.shape
C. df.count()
D. df.length()

df.shape



500

You have two lists in Python:

x = [1, 2, 3, 4] y = [10, 20, 15, 25]

Which Matplotlib command will create:

a) A bar chart of x vs y?
b) A scatter plot of x vs y?

import matplotlib.pyplot as plt

plt.bar(x, y)

plt.scatter(x, y)

plt.show()

500

sum_val = 0

for i in range(10):

    sum_val = sum_val + i

print(sum_val)

45