data-science-from-scratch icon indicating copy to clipboard operation
data-science-from-scratch copied to clipboard

The number calculating mistakes in introduction.py

Open iphyer opened this issue 10 years ago • 2 comments

The number calculating mistakes in introduction.py The length of the users list is 11 not 10 so the answer of average user's friends is 2.182 instead of 2.4.

 num_users = len(users)  # 11
 avg_connections = total_connections / num_users # 2.1818181818181817

I have changed it AND add a new comment on the line to calculate the length of users.

iphyer avatar Jun 15 '15 10:06 iphyer

I mistake you code the really problem is in the code of users.

users = [
{ "id": 0, "name": "Hero" },
{ "id": 1, "name": "Dunn" },
{ "id": 2, "name": "Sue" },
{ "id": 3, "name": "Chi" },
{ "id": 4, "name": "Thor" },
{ "id": 5, "name": "Clive" },
{ "id": 6, "name": "Hicks" },
{ "id": 7, "name": "Devin" },
{ "id": 8, "name": "Kate" },
{ "id": 9, "name": "Klein" },
{ "id": 10, "name": "Jen" } 
]

The last entry { "id": 10, "name": "Jen" } should be removed.

iphyer avatar Jun 15 '15 11:06 iphyer

+1

daniel-rhoades avatar Nov 13 '18 14:11 daniel-rhoades