August 2021
Beginner to intermediate
112 pages
1h 29m
English
| Puzzle 1 | Rectified |
| | import pandas as pd |
| | |
| | |
| | def relu(n): |
| | if n < 0: |
| | return 0 |
| | return n |
| | |
| | |
| | arr = pd.Series([-1, 0, 1]) |
| | print(relu(arr)) |
Guess the Output | |
|---|---|
|
|
Try to guess what the output is before moving to the next page. |
This code will raise a ValueError.
The problematic line is if n < 0:. n is the result of arr < 0, which is a pandas.Series.
| | In [1]: import pandas as pd |
| | In [2]: arr = pd.Series([-1, 0, 1]) ... |
Read now
Unlock full access