Skip to content

Instantly share code, notes, and snippets.

@mootrichard
Forked from jorgesancha/python_code_test_carto.md
Last active July 22, 2018 12:17
Show Gist options
  • Save mootrichard/73899639a3e405c48caedcb08b1126f3 to your computer and use it in GitHub Desktop.
Save mootrichard/73899639a3e405c48caedcb08b1126f3 to your computer and use it in GitHub Desktop.
Python code test - CARTO
#!/usr/local/bin/python3
line_count = 1
tip_amount_sum = 0
def process_line(lines):
global line_count
global tip_amount_sum
line_count += 1
tip_amount_sum += float(line.split(",")[15])
with open('yellow_tripdata_2016-01.csv', 'r') as trip_data:
for line in trip_data:
if 'tip_amount' in line:
continue
else:
process_line(line)
print('lines: {}'.format(str(line_count)))
print('tip_amount average: ${}'.format(str(round(float(tip_amount_sum/(line_count-1)),2))))

What follows is a technical test for this job offer at CARTO: https://boards.greenhouse.io/cartodb/jobs/705852#.WSvORxOGPUI

Build the following and make it run as fast as you possibly can using Python 3 (vanilla). The faster it runs, the more you will impress us!

Your code should:

All of that in the most efficient way you can come up with.

That's it. Make it fly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment