initial version of answers for babynames exercises based on daniel epstien's code
[babynames_answers] / answer_4.py
1 # 4. How many boys and girls are described in the dataset (i.e., how many boys
2 #    and girls born in 2013 have names given to at least four others)?
3
4 import ssadata
5
6 numberOfBoys = 0
7 for boysName in ssadata.boys.keys():
8         numberOfBoys = numberOfBoys + ssadata.boys[boysName]
9
10 numberOfGirls = 0
11 for girlsName in ssadata.girls.keys():
12         numberOfGirls = numberOfGirls + ssadata.girls[girlsName]
13
14 print("There are " + str(numberOfBoys) + " boys and " + str(numberOfGirls) + " girls in the data set.")
15

Benjamin Mako Hill || Want to submit a patch?