Learning Python the hard way. (2024)

Learning Python the hard way. (2)

In his “Outliers: The Story of Success”, Malcom Gladwell explains that the difference in learning experience between rich and poor kids in primary schools is not given by the kind of education they receive: comparing leading grades from both lower-income family kids and wealthy one, there’s no relevant difference during first year of school, even taking into account private and public institutes.

But then, starting the second year, things change dramatically: while middle-class and rich kids keep having good grades, poor kids show no improvement in their learning and in fact, their performance dropped.

Reason for that? Wealthy kids are able to learn even during summer, growing in a stimulating environment, having many books to read, being able to travel, attending summer camps, discovering new things and having proficient conversation with adults.

Poor kids, on other hands, spent their summer watching TV and playing with other kids in the neighbor. They are just having an all summer long break from learning.

And once back in school, the gap starts to widen. It’s the so called “Achievement Gap” (you can read an extract of this chapter here).

But does this work just for childern in primary school? Or could be true also for adults? May be the case we are more focused on making holidays plan and chilling than to learn new things?

Avoiding any doubts, I decided to challenge myself, setting the goal to learn a coding language from scratches during summer.

Learning Python the hard way. (3)

My coding skills are basically null. I did some lame experiences with VBA and Matlab when I was like…25 (damn, I’m getting old geez!), so I have to set a challenging but also doable goal.

If you’re proficient in coding, please forgive me in advance; I’m using terms such as “learning”, “understanding”, “competence”, and I’ll surely look naive to someone that spent years properly learning the language. Fair enough!

The best time to learn to code was ten years ago. The second best time, is today.

At first I was oriented toward web development, something like HTML & CSS, or maybe Javascript, but then, after some reads on Quora and other websites, and also thanks to the hints of some friends (thanks Federico and Davide), I finally decided to approach Python.

Learning Python the hard way. (4)

Python is a general-purpose language, which means it can be used to build just about anything, which will be made easy with the right tools/libraries. Professionally, Python is great for backend web development, data analysis, artificial intelligence, and scientific computing. Many developers have also used Python to build productivity tools, games, and desktop apps” (Why Learn Python).

Python is elegant, readable, and easy to understand at first, especially for someone like me that has no solid background in coding.

Suppose you’re willing to print “Hello World” to your console:

C++:

int main(){cout<<"Hello World";return 0;}

Python:

print "Hello World"

Persuasive enough, uhm?

Plus, it has tons of application, and can be relative easy to automate also everyday tasks at work or at home.

See Also
PCEP

Learning Python the hard way. (5)

Being completely open source, there are just tons of useful resources, tutorials, manuals you can get your hands on for free and learn from.

Do you know that the name “Python” is coming from “Monthy Python” and that the language was invented “for fun” by Guido van Rossum during Christmas Holiday?

“Over six years ago, in December 1989, I was looking for a “hobby” programming project that would keep me occupied during the week around Christmas. My office … would be closed, but I had a home computer, and not much else on my hands. I decided to write an interpreter for the new scripting language I had been thinking about lately: a descendant of ABC that would appeal to Unix/C hackers. I chose Python as a working title for the project, being in a slightly irreverent mood (and a big fan of Monty Python’s Flying Circus).”

In 1999, van Rossum submitted a funding proposal to DARPA called Computer Programming for Everybody, in which he further defined his goals for Python:

  • An easy and intuitive language just as powerful as major competitors
  • Open source, so anyone can contribute to its development
  • Code that is as understandable as plain English
  • Suitability for everyday tasks, allowing for short development times

I am working full time, so I needed to schedule my learning mostly after works in the evening, or at best during weekends. I wanted a practical and effective approach, at the same time preparing to commit to an hard task (learning to code basically means learning to solve problems in a finite environment).

First thing first, I needed to understand the basics. My usual approach is to get a bit of theory first, so I headed to the Python Wiki and read as much as I can, trying to comprehend as more as possible and getting the basic dictionary of the language:

I was also lucky enough to have some friend supporting me along the journey:

Annalisa gave me an invaluable hint, suggesting to install the Anaconda Distribution, together with some advice on how to smooth my dirty raw code! While Davide gave me this book, that was indeed usuful to understand the basic of data analysis.

After this quick introduction to the language, was time to get my hands on code. Among the dozen of tutorials and courses, I started from the one proposed by Codecademy:

Learning Python the hard way. (6)

I found the course incredible effective: first of all their IDLE ( Integrated Development Learning Environment) is smart and readable. It really helps breaking the ice. Consider that the course is on version 2.7, and it’s 100% free of charge.

Exercises are easy, tailored for beginner for sure, but not stupid or obvious. You have to think and try many solutions before getting the green light from the computer (only one solution is accepted for each exercise, even if many could be theoretically possible). It also include a forum where you can post your question and in ALMOST REAL TIME receive feedback from the community. The people volunteering here are great: they never offer you the solution, but they gave you hints and suggestions, forcing you to think again and finally solve the problem on your own.

After finishing the online course, I feel “competent” enough to install Python on my machine (I’m running on Windows) and try to develop some projects on my own.

Firstly I tried the raw Python install. But I don’t like the work environment, and I also made a mistake installing Python 3.0 (as stated above, I did the course on 2.7, and there are some slight, but significant differences. The code written on 2.7 would not run on 3.0 unless tweaked a bit). Also, looks like installing Python to path (so you can basically run with from your command prompt) is discouraged on Windows.

After this unsuccessful trial, I proceeded with Anaconda Distribution.

Anaconda is a freemium, open source, distribution of the Python and R programming languages for large-scale data processing, predictive analytics, and scientific computing, that aims to simplify package management and deployment. It comes with Spyder, an incredible effective and easy to use IDE. I liked it immediately:

Learning Python the hard way. (7)

Aside that, I wanted to have also an online repository for my codes. I picked the most basic yet likable solution possible: Repl

Repl is a simple online IDE, not just for Python but for many languages such as JavaScript, C++, Ruby, HTML, and more.

I like it since it easily allows me to write, check and share code from any pc and mobile. I’m using it also as online repository for my projects. It’s effective and easy. I like it a lot!

My “summer project” is almost over. Time to drawn some conclusions about it!

0. Surely I haven’t learned “how to code”. That would have been a whole different learning process, I won’t claim this. But it was a very profitable exercise anyway! I also grown interest in Python and in programming languages in general and I’ll likely invest more time in the future to learn about it.

  1. Firstly, I learned to read programming languages a bit.

While first, looking at a complex code, I would immediately discharge it, thinking “there’s no way I can understand what’s going on here”, now I’m thinking “ok, let’s see if I’m able to get something out of this mess”.

It’s a bit tricky to explain this, but it’s like I gave myself the “permission” to try to read and understand code. I am at least able to break a complex script or algorithm in little chunks I can understand, or at least search for their meaning on Stack Overflow or GitHub.

This is probably the most valuable lesson I get from the whole project.

2. Learning to code is hard, so, implicitly, I strengthen my problem solving attitude (even better: “the code is easy, it’s solving the problem that is hard”). It’s a mindset: there’s this problem, and you have to rely on your expertise only to solve it.

Last week, my gf needed help to fix an issue with an HTML string on her website. Usually, I would have searched for a solution straight on Google. But this time, I patiently read thru the lines until I found a little “<” missing. Fixed and solved. It was like Xmas to me that day :)

“It’s not that I’m so smart, it’s just that I stay with problems longer.”

Albert Einstein

3. Then, I was able to develop some little project on my own. The classic exercises for beginner, but very interesting nevertheless (click on the link to see and try the code on my repl repository):

4. I spent also some nights on Pygame! Pygame is a free and open source Python programming language library for making multimedia applications like games built on top of the excellent SDL library.

In a week I was able to write my PONG! code…hell yeah! (I also read that a proficient student can write this code in 20 minutes, but ok that’s another story!)

Learning Python the hard way. (8)
  1. There’s a version of Doom ported to Python: PyDoom. This port has been created and maintained by a girl, Kate Stone :)
  2. There’s a random number of Python quests and trivia around the web. One of the most famous, and also pretty challenging, is this one: http://www.pythonchallenge.com/
  3. There are tons of website proposing online courses; one of the most famous is https://learnpythonthehardway.org/ from which I also took inspiration for the title of this article.
  4. You can find entire threads of people hating on Python.
  5. I found, and more than once, terrific Python programs written by kids! Like “looks at this tool for predicting house prices I wrote at age 8”. Ridiculous.
  6. Zen of Python is a thing, and it’s also pretty famous.
  7. There’s a huge amount of Python pranks around the web. For example this one will make your CD-ROM goes crazy until you kill the application. It works :)
  8. Spotify, YouTube, Instagram, Dropbox, as well as Civilization IV are mainly based on Python code.
  9. Openstack (the cloud architecture adopted by NASA and CERN) is reasonably the most complex Python code ever: it counts 2'400'000 lines. Good luck for debugging that beast then…
  10. But it’s also possible to wrote a very complex algorithms in less than 50 lines: here’s how you can predicting Stock Prices in 50 lines of Python.

I liked very much the idea of having a summer goal, probably I’ll have again a similar project next summer.

And you? Do you worked on a special project this summer? Or did you learn something new? Let me know in the comments. And if you liked the article, let me know with some claps 👏!

And remember, “it’s not a bug, it’s a feature”. :)

Learning Python the hard way. (2024)

FAQs

Is learning Python the hard way worth it? ›

Learn Python the Hard Way by Zed A. Shaw is an excellent learning resource for the beginning Python programmer. Don't be turned off by the "hard way" bit; the book's exercises are well thought out and pedagogically sound. In fact, doing things the "hard way" will actually make you a better programmer in the end.

How long does it realistically take to learn Python? ›

On average, it can take anywhere from five to 10 weeks to learn the basics of Python programming, including object-oriented programming, basic Python syntax, data types, loops, variables, and functions.

Can the average person learn Python? ›

Yes, it's very possible to learn Python on your own. There are many learning resources available on the web to help you learn Python for everything from web development to artificial intelligence.

Top Articles
Latest Posts
Article information

Author: Roderick King

Last Updated:

Views: 5900

Rating: 4 / 5 (51 voted)

Reviews: 82% of readers found this page helpful

Author information

Name: Roderick King

Birthday: 1997-10-09

Address: 3782 Madge Knoll, East Dudley, MA 63913

Phone: +2521695290067

Job: Customer Sales Coordinator

Hobby: Gunsmithing, Embroidery, Parkour, Kitesurfing, Rock climbing, Sand art, Beekeeping

Introduction: My name is Roderick King, I am a cute, splendid, excited, perfect, gentle, funny, vivacious person who loves writing and wants to share my knowledge and understanding with you.