2020-08-13 12:00:20 +02:00
|
|
|
---
|
|
|
|
id: 5e9a093a74c4063ca6f7c161
|
|
|
|
challengeType: 11
|
|
|
|
videoId: cDnt02BcHng
|
|
|
|
---
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
# --description--
|
2020-08-13 12:00:20 +02:00
|
|
|
|
|
|
|
More resources:
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
\- [Reading CSVs Notebook](https://notebooks.ai/rmotr-curriculum/rdp-reading-csv-and-txt-files-fb829f46)
|
2020-08-13 12:00:20 +02:00
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
\- [Reading SQL](https://notebooks.ai/rmotr-curriculum/rdp-reading-data-from-relational-databases-2a3a889b)
|
2020-08-13 12:00:20 +02:00
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
\- [Reading HTML](https://notebooks.ai/rmotr-curriculum/rdp-reading-html-tables-eb9cca73)
|
2020-08-13 12:00:20 +02:00
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
\- [Reading Excel files](https://notebooks.ai/rmotr-curriculum/rdp-reading-excel-files-a6b99973)
|
2020-08-13 12:00:20 +02:00
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
# --question--
|
2020-08-13 12:00:20 +02:00
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
## --text--
|
2020-08-13 12:00:20 +02:00
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
Given a file named `certificates.csv` with these contents:
|
2020-08-13 12:00:20 +02:00
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
```
|
|
|
|
Name$Certificates$Time (in months)
|
|
|
|
Tom$8$16
|
|
|
|
Kris$2$5
|
|
|
|
Ahmad$5$9
|
|
|
|
Beau$6$12
|
|
|
|
```
|
2020-08-13 12:00:20 +02:00
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
Fill in the blanks for the missing arguments below:
|
2020-08-13 12:00:20 +02:00
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
```py
|
|
|
|
import csv
|
2020-08-13 12:00:20 +02:00
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
with open(__A__, 'r') as fp:
|
|
|
|
reader = csv.reader(fp, delimiter=__B__)
|
|
|
|
next(reader)
|
|
|
|
for index, values in enumerate(reader):
|
|
|
|
name, certs_num, months_num = values
|
|
|
|
print(f"{name} earned {__C__} certificates in {months_num} months")
|
|
|
|
```
|
2020-08-13 12:00:20 +02:00
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
## --answers--
|
2020-08-13 12:00:20 +02:00
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
A: `'certificates.csv'`
|
2020-08-13 12:00:20 +02:00
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
B: `'-'`
|
|
|
|
|
|
|
|
C: `values`
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
A: `'certificates.csv'`
|
|
|
|
|
|
|
|
B: `'$'`
|
|
|
|
|
|
|
|
C: `certs_num`
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
A: `'certificates'`
|
|
|
|
|
|
|
|
B: `'$'`
|
|
|
|
|
|
|
|
C: `certs_num`
|
|
|
|
|
|
|
|
## --video-solution--
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
|
# --hints--
|
|
|
|
|
|
|
|
|
|
|
|
# --solutions--
|
2020-08-13 12:00:20 +02:00
|
|
|
|