2015 April

median exercise on Codecademy Python course

Posted by | English, Programming, Python | No Comments

I recently wanted to test out my fresh Python skills by doing a Codecademy Python course. I really like the way they explain things and even a complete beginner can start comfortably not just by reading trough pages of documentation, but by seeing examples and putting them to use on their online interpreter. I’ll be doing other courses they have over there for sure, and I highly recommend it, if you’re exploring a new language or are completely new to programming.

During a final exercise called median (under Loops / Practice Makes Perfect) I stumbled upon a first anomaly that I met up until now. The instructions are as follows:

Write a function called median that takes a list as an input and returns the median value of the list.

For example: median([1,1,2]) should return 1.

  1. The list can be of any size and the numbers are not guaranteed to be in any particular order.
  2. If the list contains an even number of elements, your function should return the average of the middle two.

I wrote the function, but line of code that calculated the average of two numbers didn’t quite work:

return (int(sorted_lst[0]) + int(sorted_lst[1])) / 2

Read More


Posted by | English, Programming | No Comments

I’ve been diving in to the world of programming for about a year, as a hobby. Not having a job has its perks too, I’m trying to make out the most of the free time I have now by learning new things. So I started with C and C++, and learned quite a lot about embedded systems as well. It hasn’t been easy, but I feel like, I’m slowly making some progress. I’ve done some projects on a ARM Cortex M4 based board, and found the process of low-level tinkering very satisfying. Props go to my girlfriend for guidance and support, she has a lot of field experience and knows winIDEA inside out. I also wrote a few lines in Python a few months ago and fell in love with it.

So I’ve decided to to start blogging on this matter here in English. My posts will be about things that I find interesting in the process of learning and projects I’ll be working on in the future.

Stay tuned! :)