wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

L13 Python

Total questions: 37

Worksheet time: 37mins

Name
Class
Date
1.
What does the mean of a dataset represent?
a)
The average value of the dataset
b)
The most frequent value
c)
The middle value
d)
The range of values
2.
What is the mode of [2, 2, 3, 4, 4, 4, 5]?
a)
4
b)
2
c)
3
d)
5
3.

Output of this code?

import pandas as pd
s = pd.Series([1,2,3,4,5]) s.mean ()

a)

3.0

b)
2
c)
5
d)
Produces error
4.

Output of this code?
s = pd.Series ([1,2,3,4,5]) s.median()

a)
3
b)
2
c)
4
d)
5
5.

Output of this code?
s = pd.Series ([1,2,2,3,4]) s.mode()

a)
0 2 dtype: int64
b)
0 1 dtype: int64
c)
0 3 dtype: int64
d)
Produces error
6.

How do you compute variance using pandas?
s.var()

a)
Returns variance of the series
b)
Returns standard deviation
c)
Returns mean
d)
Produces error
7.

Output of this code? import pandas as pd
s = pd. Series ([1,2,3,4,5]) s.mean()

a)
3,0
b)
2
c)
5
d)
Produces error
8.
What is the median of [1, 3, 5, 7, 9]?
a)
5
b)
3
c)
7
d)
25
9.

How do you compute standard deviation using pandas?
s.std()

a)
Returns standard deviation of the series
b)
Returns variance
c)
Returns mean
10.

Output of this code?
import numpy as np
np.var([1,2,3,4])

a)
1.25
b)
2
c)
1
d)
Produces error
11.

Output of this code?
np.std ([1,2, 3,4])

a)
1.118033988749895
b)
1.25
c)
2
d)
Produces error
12.

What is covariance?

a)
Measure of how two variables vary together
b)
Measure of central tendency
c)
Measure of frequency
d)

Measure of distribution

13.

Output of this code?
df = pd. DataFrame ({'X': [1,2,3], 'Y': [4,5,6]})

df.cov()

a)

X Y X 1.0 1.0 Y 1.0 1.0

b)

X Y X 0 0 Y 0 0

c)

Produces error

d)

Returns series

14.

Output of this code?

df.corr()

a)
X Y X 1.0 1.0 Y 1.0 1.0
b)
X Y X 0 0 Y 0 0
c)
Produces error
d)
Returns series
15.
What does describe() provide in pandas?
a)
Count, mean, std, min, quartiles, max
b)
Only mean and median
c)
Only max and min
d)
Only sum
16.

Output of this code?
s = pd. Series ([1, 2, 3, 4, 5])
s.describe()

a)
count 5.0 mean 3.0 std 1.581139 min 1.0 25% 2.0 50% 3. 75% 4.0 max 5.0 dtype: float64
b)
Only mean and std
c)
C min and max
d)
Produces error
17.

How do you compute quantiles?
s.quantile(0.25)

a)
Returns 25th percentile
b)
Returns median
c)
Returns max
d)
Produces error
18.

Output of this code?
from scipy.stats import zscore
import pandas as pd
a = pd.Series([1,2,3,4,5]).zscore(s)

a)
array([-1.41421356, -0.70710678, O., 0.70710678, 1.414213561)
b)
array([1,2,3,4,5])
c)
array([0,0,0,0,0])
d)
Produces error
19.

How do you compute cumulative sum?
s.cumsum ()

a)
Returns running total of the series
b)
Returns mean
c)
Returns max
d)
Produces error
20.

How do you compute cumulative product?
s.cumprod ()

a)
Returns running product
b)
Returns sum
c)
Returns mean
d)
Produces error
21.

How do you compute correlation between two series?
s1.corr(s2)

a)
Returns correlation coefficient
b)
Returns covariance
c)
Returns mean difference
d)
Produces error
22.

What does this code output?
df = pd.DataFrame ({'A': (1,2,3,4, 5]})
df.var()

a)
A 2.5 dtype: float64
b)
A 1.0 dtype: float64
c)
A 5.0 dtype: float64
d)
Produces error
23.
What is the probability of event A in a uniform distribution with 4 equally like outcomes?
a)
0.25
b)
0.5
c)
0.75
d)
1
24.
What is the expected value of [1, 2, 3, 4]?
a)
2.5
b)
2
c)
3
d)
4
25.

How do you compute sample standard deviation in numpy?
np.std([1,2, 3, 4], ddof=1)

a)
1.2909944487358056
b)
1.118
c)
1.25
d)
Produces error
26.

How do you compute sample variance in numpy?
np.var ([1,2, 3,4], ddof=1)

a)
1.6666666666666667
b)
1.25
c)
2
d)
Produces error
27.

What is the output?
s = pd.Series ( [1,2,3,4,5])
s.max () - s.min ()

a)
4
b)
5
c)
3
d)
Produces error
28.

How do you compute range of a series?
s.ptp()

a)
Returns max-min
b)
Returns sum
c)
Returns mean
d)
Produces error
29.

How do you compute interquartile range?
s.quantile(0.75) - s. quantile(0.25)

a)
Returns difference between 75th and 25th percentile
b)
Returns difference between max and min
c)
Returns standard deviation
d)
Produces error
30.

What will be the output of this code?
import pandas as pd
import numpy as np
df = pd.DataFrame ({'A': [1,2,3,4,5], 'B': [5,4,3,2,1]})
df.corr (method = 'kendall')

a)
A B A 1.0 -1.0 B -1.0 1.0
b)
A B A 1.0 1.0 B 1.0 1.0
c)
Produces error
d)
A B A 0.5 -0.5 B -0.5 0.5
31.

What will be the output of this code?
s = pd.Series ([1,2,2,3, 3,3, 4, 4,4,4])
s.value_counts(normalize=True)

a)
4 0.4 3 0.3 2 0.2 1 0.1 dtype: float64
b)
4 4 3 3 2 2 1 1 dtype: int64
c)
Produces error
d)
1 0.1 2 0.2 3 0.3 4 0.4
32.

What does this code compute?
s = pd.Series.([1,2,3,4,5])
np.mean(np.square (s-s.mean ()))

a)
Computes population variance
b)
Computes sample variance
c)
Computes standard deviationnance
d)
Computes z-scores
33.

Output of this code?
s = pd.Series ([1,2,3,4,5])
((s - s.mean ()) / s.std()).sum()

a)
Approximately 0
b)
5
c)
1
d)
Produces error
34.

What does this code compute?
df = pd.DataFrame ({'A': [1,2,3,4,5], 'B': [2,4, 6,8,10]})
df.apply(lambda x: (x - x.mean ()) / x.std ())

a)
Standardizes each column (z-scores)
b)
Normalizes between 0 and 1'
c)
Computes cumulative sum
d)
Produces error
35.

Output of this code?
s = pd.Series([1,2,3,4,5])
s.rolling(3).apply (lambda x: np.prod (x))

a)
0 NaN 1 NaN 2 6.0 3 24.0 4 60.0 dtype: float64
b)
0 1 1 2 2 6 3 24 4 120 dtype: int64
c)
Produces error
d)
0 NaN 1 NaN 2 NaN 3 NaN 4 NaN
36.

What will be the output of this code?
from scipy.stats import pearsonr
x = [1,2,3,4,5]
y = [2,3,5,7,11]
pearsonr(x,y)

a)
(0.9912407071619302, 0.000986) # correlation coefficient and p-value
b)
(1.0,0)
c)
(0.5, 0.1)
d)
Produces error
37.

What will this code output?
df = pd.DataBrameK({At: [1,2,3/4,5]})
df.diff().sum()

a)
A 4 dtype: int64
b)
A 5 dtype: int64
c)
A 0 dtype: int64
d)
Produces error