Pub Quiz

Create your team

  • You can be from 3 to 5 people
  • Get a blue and a red pen and a sheet of paper
  • Write at the top of the paper:
    • Your team name
    • The names of the members of your team

How it works?

Questions

  • There will be 5 rounds
  • Each round has one question of each of the next categories:
    1. What's the output of the script?
      • consider the latest version of CPython and libraries
    2. PyData community
    3. Which library is it?
    4. Monty Python
    5. Python version
    6. Barcelona
  • For each answer write:
    • The round
    • The question
    • In the format R1Q1
  • You can't check your phones, tablets, laptops... during the rounds

How it works

Answers

  • At the end of each round, we'll give the answers
  • Give your paper with the answers to the team next to you
  • Write in red the points:
    • 0 for wrong answers
    • 1 for right answers
    • 3 for exceptionally good answers (we'll let you know)
  • At the end, add up all the answers, and report the total

Example

R9Q9 - Which library is it?

import who_am_i as wai


df = wai.read_csv('some_clean_data.csv',
                  parse_dates=True,
                  index_col='id')
df.describe()
df['val'].plot()

Write in your paper:

  • R1Q1: pandas

Points to other teams:

  • R1Q1: pandas 1

Round 1

R1Q1: What's the output?

>>> first, *middle, last = range(10)
>>> other = [last] * 8
>>> sum(zip(middle, other), tuple())[::2]

R1Q2: Community

Who is the creator of Pandas, and author of the book Python for Data Analysis?

R1Q3: Which library is it?

>>> import who_am_i as wai
>>> import numpy as np
>>>
>>> t = np.arange(0.0, 2.0, 0.01)
>>> s = 1 + np.sin(2 * np.pi * t)
>>> wai.plot(t, s)
>>> wai.xlabel('Some numbers')
>>> wai.ylabel('Sine')
>>> wai.title('Sine of some numbers')
>>> wai.grid(True)
>>> wai.show()

R1Q4: Monty Python

From which Monty Python movie is this frame?

R1Q5: Python version

Since which version of Python this is valid Python code?

>>> earth_radius = 6_371
>>> print(f'The radius of earth is {earth_radius}')

R1Q6: Python Barcelona

How many meetups, the Barcelona Python Meetup has held until today?

Round 1: Answers

R1Q1: What's the output?

>>> first, *middle, last = range(10)
>>> other = [2] * 8
>>> sum(zip(middle, other), tuple())[::2]

(1, 2, 3, 4, 5, 6, 7, 8) → 3

[1, 2, 3, 4, 5, 6, 7, 8] → 1

R1Q1: What's the output?

>>> first, *middle, last = range(10)
>>> first
0
>>> middle
[1, 2, 3, 4, 5, 6, 7, 8]
>>> last
9

>>> other = [last] * 8
>>> other
[9, 9, 9, 9, 9, 9, 9, 9]

>>> zip_val = list(zip(middle, other))
>>> zip_val
[(1, 9), (2, 9), (3, 9), (4, 9), (5, 9), (6, 9), (7, 9), (8, 9)]

>>> sum_val = sum(zip_val, tuple())
>>> sum_val
(1, 9, 2, 9, 3, 9, 4, 9, 5, 9, 6, 9, 7, 9, 8, 9)

>>> sum_val[::2]
(1, 2, 3, 4, 5, 6, 7, 8)

>>> sum(zip(middle, other), tuple())[::2]
(1, 2, 3, 4, 5, 6, 7, 8)

R1Q2: Community

Who is the creator of Pandas, and author of the book Python for Data Analysis?

Wes McKinney → 3

With wrong spelling → 1

R1Q3: Which library is it?

>>> import who_am_i as wai
>>> import numpy as np
>>>
>>> t = np.arange(0.0, 2.0, 0.01)
>>> s = 1 + np.sin(2 * np.pi * t)
>>> wai.plot(t, s)
>>> wai.xlabel('Some numbers')
>>> wai.ylabel('Sine')
>>> wai.title('Sine of some numbers')
>>> wai.grid(True)
>>> wai.show()

matplotlib.pyplot → 3

matplotlib → 1

R1Q3: Which library is it?

>>> import matplotlib.pyplot as plt
>>> import numpy as np
>>>
>>> t = np.arange(0.0, 2.0, 0.01)
>>> s = 1 + np.sin(2 * np.pi * t)
>>> plt.plot(t, s)
>>> plt.xlabel('Some numbers')
>>> plt.ylabel('Sine')
>>> plt.title('Sine of some numbers')
>>> plt.grid(True)
>>> plt.show()

R1Q4: Monty Python

From which Monty Python movie is this frame?

The meaning of life → 3

El sentido de la vida / El sentit de la vida → 3

R1Q5: Python version

Since which version of Python this is valid Python code?

>>> earth_radius = 6_371
>>> print(f'The radius of earth is {earth_radius}')

CPython 3.6 → 3

Returns 'The radius of earth is 6371' in Python 3.6, and SyntaxError in all previous version, because of the underscore in the number literal, and the f-string.

R1Q6: Python Barcelona

How many meetups, the Barcelona Python Meetup has held until today?

Exactly 100 → 3

Between 80 and 120 → 1


In [7]:
import itertools
import random
import bisect

candidates = [0, 99, 666, 22]
weights = [.33, .33, 99., .34]
cum_weights = itertools.accumulate(weights)
candidates[bisect.bisect(cum_weights, random.random() * cum_weights[-1])]


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-7-76cc035203d4> in <module>()
      6 weights = [.33, .33, 99., .34]
      7 cum_weights = itertools.accumulate(weights)
----> 8 candidates[bisect.bisect(cum_weights, random.random() * cum_weights[-1])]

TypeError: 'itertools.accumulate' object is not subscriptable

Round 2

R2Q1: What's the output?

>>> import itertools
>>> import random
>>> import bisect
>>> 
>>> candidates = [0, 99, 666, 22]
>>> weights = [.33, .33, 99., .34]
>>> cum_weights = itertools.accumulate(weights)
>>> candidates[bisect.bisect(cum_weights, random.random() * cum_weights[-1])]

R2Q2: Community

Which of these projects is not a NumFOCUS fiscally sponsored project?

R2Q3: Which library is it?

>>> import who_am_i as wai
>>> import numpy as np
>>> from sklearn.pipeline import make_pipeline
>>> from sklearn.dummy import DummyClassifier
>>>
>>> X = np.array([[ 1., -1.,      2.],
...               [ 2.,  np.nan,  0.],
...               [ 0.,  1.,     -1.]])
>>> y = np.array([0., 1., 0.])
>>>
>>> clf = make_pipeline(wai.Imputer(),
...                     wai.StandardScaler(),
...                     DummyClassifier())
>>>
>>> clf.fit(X, y)
>>> clf.predict(np.array([[2., 0., -1.]]))

R2Q4: Monty Python

Which is the biggest enemy of the People's Front of Judea?

R2Q5: Python version

Which is the latest released version of Pandas?

R2Q6: Python Barcelona

Who was the founder of the Barcelona Python Meetup?

Round 2: Answers

R2Q1: What's the output?

>>> import itertools
>>> import random
>>> import bisect
>>> 
>>> candidates = [0, 99, 666, 22]
>>> weights = [.33, .33, 99., .34]
>>> cum_weights = list(itertools.accumulate(weights))
>>> cum_weights
[0.33, 0.66, 99.66, 100.0]
>>> random_number = random.random() * cum_weights[-1]
>>> # uniformly distributed between 0 and 100
>>> # 99% probability of being between 0.66 and 99.66
>>> random_number
58.95397201789591
>>> index = bisect.bisect(cum_weights, random_number)
>>> index
2
>>> candidates[index]
666

R2Q1: What's the output?

>>> import itertools
>>> import random
>>> import bisect
>>> 
>>> candidates = [0, 99, 666, 22]
>>> weights = [.33, .33, 99., .34]
>>> cum_weights = itertools.accumulate(weights)
>>> candidates[bisect.bisect(cum_weights, random.random() * cum_weights[-1])]
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-7-76cc035203d4> in <module>()
      6 weights = [.33, .33, 99., .34]
      7 cum_weights = itertools.accumulate(weights)
----> 8 candidates[bisect.bisect(cum_weights, random.random() * cum_weights[-1])]

TypeError: 'itertools.accumulate' object is not subscriptable

TypeError → 3

666 with 99% probability → 1

R2Q2: Community

Which of these projects is not a NumFOCUS fiscally sponsored project?

R2Q2: Community

Which of these projects is not a NumFOCUS fiscally sponsored project?

Gensim → 3

R2Q3: Which library is it?

>>> import who_am_i as wai
>>> import numpy as np
>>> from sklearn.pipeline import make_pipeline
>>> from sklearn.dummy import DummyClassifier
>>>
>>> X = np.array([[ 1., -1.,      2.],
...               [ 2.,  np.nan,  0.],
...               [ 0.,  1.,     -1.]])
>>> y = np.array([0., 1., 0.])
>>>
>>> clf = make_pipeline(wai.Imputer(),
...                     wai.StandardScaler(),
...                     DummyClassifier())
>>>
>>> clf.fit(X, y)
>>> clf.predict(np.array([[2., 0., -1.]]))

sklearn.preprocessing → 1

R2Q3: Which library is it?

>>> import sklearn.preprocessing
>>> import numpy as np
>>> from sklearn.pipeline import make_pipeline
>>> from sklearn.dummy import DummyClassifier
>>>
>>> X = np.array([[ 1., -1.,      2.],
...               [ 2.,  np.nan,  0.],
...               [ 0.,  1.,     -1.]])
>>> y = np.array([0., 1., 0.])
>>>
>>> clf = make_pipeline(sklearn.preprocessing.Imputer(),
...                     sklearn.preprocessing.StandardScaler(),
...                     DummyClassifier())
>>>
>>> clf.fit(X, y)
>>> clf.predict(np.array([[2., 0., -1.]]))
array([ 1.])

if you also knew the prediction is 1. → 3

R2Q4: Monty Python

Which is the biggest enemy of the People's Front of Judea?

The Judean People's Front → 3

The Romans → -1

R2Q5: Python version

Which is the latest released version of Pandas?

pandas 0.20.1 → 3

pandas 0.20 → 1

R1Q6: Python Barcelona

Who was the founder of the Barcelona Python Meetup?

Maik Röder → 5


In [ ]: