Python Koans: Learn Python Programming By Making Tests Pass

Python Koans is an interactive tutorial for learning the Python programming language by making tests pass.

Most tests are fixed by filling the missing parts of assert functions. Eg:

self.assertEqual(__, 1+2)

which can be fixed by replacing the __ part with the appropriate code:

self.assertEqual(3, 1+2)

Occasionally you will encounter some failing tests that are already filled out. In these cases you will need to finish implementing some code to progress. For example, there is an exercise for writing some code that will tell you if a triangle is equilateral, isosceles or scalene.

As well as being a great way to learn some Python, it is also a good way to get a taste of Test Driven Development (TDD).

GitHub - gregmalcolm/python_koans: Python Koans - Learn Python through TDD

I remember when I stumbled upon this gem. It was like finding buried treasure! Each test is like a challenge waiting to be conquered. Sometimes you breeze through, filling in the blanks with the missing code. Other times, you hit a roadblock – a failing test staring you down, daring you to crack the code.

Bookmarked for later use

One time, I came across a test for classifying triangles – equilateral, isosceles, or scalene. Let me tell you, that one had me scratching my head for a minute! But with a little perseverance and some trial and error, I finally cracked it. And let me tell you, the satisfaction of seeing all those tests turn green? Priceless. But Python Koans isn’t just about learning Python. It’s also a sneak peek into TDD. Learning to write tests before code? It’s a whole new way of thinking, but trust me, it’s worth it. But if you’re itching for more Python adventures, Hire Python Developer They can be helpful, too.