It's not that I'm so smart, it's just that I stay with problems longer. - A. Einstein
Hi Pythonistas, this is a very special edition! Today, the 10th of November, we launch our first Live Code Challenge. We partnered up with Python Alicante and we will be hosting this code challenge with them at the University of Alicante. If you don't happen to live in Alicante but do want to code today 10am-13pm CET you are more than welcome to join this Gitter channel.
We all love Marvel, don't you? So here's the deal: we found a CSV with Marvel data taken from this database.
We are going to have you write some Python to get this data into a usable data structure to answer some questions about the data.
(repo available shortly before start challenge 10/11/2017 10 am CET)
After forking the repo make sure you checkout the community branch:
# https $ git clone https://github.com/<your_user>/marvel_challenge -b community # or use SSH $ git clone firstname.lastname@example.org:<your_user>/marvel_challenge.git -b community
Create your own branch:
$ cd marvel_challenge $ git checkout -b PCC44
marvel.py in your favorite editor.
Code your solution (see next section)
Verify your solution:
$ python test_marvel.py ..... ---------------------------------------------------------------------- Ran 5 tests in 0.424s OK
Submit your solution by pushing your branch to
$ git push origin PCC44
Then browse to your fork and open a PR again our repo -> community branch. No worries we are happy to help you if you get stuck.
marvel.py has already some stubs, here is what we want you to try:
marvel-wikia-data.csv CSV file and load it into a data structure. You probably want a list of dicts or namedtuples, one for each row. Store this in
data which will be in the module's namespace (already done in the template).
Get the most popular characters based on the number of appearances they made in comics over the years.
Get the year with most and least new Marvel characters introduced respectively, return a (max_year, min_year) tuple. Expect min/max to be pretty far apart.
What percentage of the comics characters is female? Please give us the percentage rounded to 2 digits.
Good vs bad characters: return a dictionary of bad vs good vs neutral characters per sex. The keys are Bad Characters, Good Characters, Neutral Characters, the values are integer percentages. Who plays the villain more often, a man or a woman?
OK you know Python inside out, and this was pretty easy. Sounds like you? Please surprise us with:
Here for example we used Bokeh to plot newly introduced characters per year:
There are 2 conditions though:
We will determine the winner by a simple algorithm: solution * 0.5 + speed * 0.3 + design * 0.2 (does it work / how fast did you PR / PEP8 + code quality)
You like these challenges? We have published quite a few and we're not planning to stop anytime soon.
You really like them and plan on PR'ing more in the future? Then consider joining our private Slack channel sending us an email. This way you get the unique opportunity to learn from other passionate Pythonistas and share some of your experience.
Our goal is to learn and teach you Python through practical exercises. Learning a programming language is way more fun as a community!
Keep Calm and Code in Python!
Do you want to get 250+ concise and applicable Python tips in an ebook that will cost you less than 10 bucks (future updates included), check it out here.
"The discussions are succinct yet thorough enough to give you a solid grasp of the particular problem. I just wish I would have had this book when I started learning Python." - Daniel H
"Bob and Julian are the masters at aggregating these small snippets of code that can really make certain aspects of coding easier." - Jesse B
"This is now my favourite first Python go-to reference." - Anthony L
"Do you ever go on one of those cooking websites for a recipe and have to scroll for what feels like an eternity to get to the ingredients and the 4 steps the recipe actually takes? This is the opposite of that." - Sergio S