This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import csv | |
| collisions = list(csv.DictReader(open('dft-road-casualty-statistics-collision-1979-latest-published-year.csv'))) | |
| print("Row count, 1979-present:", len(collisions)) | |
| fatal_collisions = [row for row in collisions if row['collision_severity'] == '1'] | |
| print("Of those,", len(fatal_collisions), "were fatal") | |
| correct_years_collisions = [row for row in fatal_collisions if 2005 <= int(row['collision_year']) <= 2018] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # A simulation to settle a Twitter argument: | |
| # https://twitter.com/brenorb/status/1213898659752038400 | |
| import random | |
| random.seed(42) # For reproducible results | |
| # We have four possible scenarios we can simulate, based on these two bools. | |
| # The first determines whether it's permissible for the host to reveal the car | |
| # on the first door-opening. The second determines whether the contestant is | |
| # using an "always swap" strategy or an "always stick" strategy. |