Like many other people, when the pandemic started and it was obvious we would all have more time on our hands, I decided it was time to write my novel. And just like many other people, I've spent more quality time with my Netflix watchlist than a pen and paper.
The same isn't true for Miki Tebeka, CEO at 353Solutions, a consultancy and workshop provider, and author of Python Brain Teasers, published by The Pragmatic Bookshelf. He began work on the book of Python exercises when the lockdowns started and found more time on his hands.
"I like to think about problems and teasers and examples to teach," Tebeka said.
Tebeka said he has worked with Python for many years and currently teaches workshops on the programming language. One of the benefits of Python Brain Teasers is that it makes learning the quirks of Python fun.
"I want to make it something that is fun to do and also something educational," Tebeka said.
Where to start?
While Python Brain Teasers was written with advanced Python coders in mind, it's important to start somewhere. And the best place for each of us to start depends on the individual.
"Some people are self-motivated, and they like to do things on their own and struggle with things," Tebeka said. "Some people need more structure when they're beginning. ... So, it really depends on your learning style."
Many beginners start with bootcamps and workshops designed to teach the basics of Python. One of the biggest tips for learning Python that Tebeka recommended is getting involved in a coding community.
Tebeka said it's easy to get involved on Twitter, where some people will tweet Python brain teasers similar to the ones he presents in his book. There are also chat communities in Slack and Discord where programmers can connect with other coders and get fast responses to questions. Social media is also a great way to connect. Tebeka mentioned Twitter specifically, but there are also thriving communities on Reddit, such as r/learnpython and r/Python, where code writers connect.
"One thing I really like about the Python community is there's a lot of emphasis on being a friendly community," Tebeka said. "They don't like people who are rude. That's really discouraging."
Miki TebekaCEO, 353Solutions
Expanding your Python knowledge
Learning a programming language isn't so different from learning a second spoken language. Continued learning is important to both. For spoken languages, that means reading, writing and speaking the language as much as possible. For coding, it means reading codes by good developers and, especially, writing code to expand your abilities.
"We can read code, and it's a good idea to read from people who are really good developers," Tebeka said. "But writing code is by far the most efficient."
While his book is geared more toward advanced code writers, there are plenty of similar fun, puzzle-oriented Python exercises for practice at the beginner level. One example Tebeka suggested is the Advent of Code, an annual event in December with 25 days of Christmas-themed puzzles.
"They don't take a lot of time," Tebeka said. "I find them fun, too."
The importance of understanding
Among other tips for learning Python, Tebeka recommended questioning and trying to understand the why.
According to him, it's not uncommon for programmers to ask for help in Python communities, get an answer and just copy and paste the code. Sometimes that will work, but it might not always be the best solution.
"What I tried to do in the teasers is -- apart from saying 'this is what's going to be printed out' -- I wanted to give an explanation of 'this is why it's happening,'" Tebeka said.
Additionally, getting a critique of your code can help with understanding and advancing abilities. Tebeka said pair programming or code reviews offer a lot to learn from. And curiosity goes a long way.
"I would argue that curiosity is the best thing," he said.
Take a whirl
So, what does a Python brain teaser look like? Check out this example from Python Brain Teasers by Miki Tebeka, published by The Pragmatic Bookshelf.