Archive for the ‘Programing’ Category

How to Prepare for a Python Coding Interview

A “minimalist guide” on how to prepare for your upcoming Python interview in three steps.

Participating in a “Silicon Valley style” coding interview can feel scary as heck.

Unlike other professionals, it seems to be okay for software developers to expect to get humiliated at a job interview:

“What, you can’t code up a recursive descent parser on a whiteboard in 7.5 minutes? How DARE YOU
even apply for this job!”

Yeah, … Read the rest

Here I use Python and agent-based modelling with Mesa to solve a game theory problem in FiveThirtyEight’s Riddler.Read the rest

Recently, when I was having fun with algorithms exercises, I though, do I solve them correctly?
So I thought that it would be neat to somehow find the complexity of an algorithm.

Gathering the data

The first idea was to use timeit and
calculate complexity based on consumed time:

import timeit
from numpy.random import randint def _get_data_set(size): return list(randint(1000, size=size)) def main(alist): for passnum in range
Read the rest

Subtests are the best

Testing our code is important. Because developers write bugs, it’s valuable to catch and correct them before the code gets to production so our apps work as they should. Specifically, we want tests that are DRY (Don’t Repeat Yourself), thorough, and readable. Though there are many ways to try to accomplish these goals, subtests make each of them easier. If you’re not using subtests in your test classes, you probably should be.

Subtests were introduced in

Read the rest

Regular expressions are text matching patterns described with a formal syntax. The patterns are interpreted as a set of instructions, which are then executed with a string as input to produce a matching subset or modified version of the original. The term “regular expressions” is frequently shortened to as “regex” or “regexp” in conversation. Expressions … Continue reading re — Regular Expressions — PyMOTW 3

Read the rest

This week we welcome Terry Peppers (@club_is_open) as our PyDev of the Week. Terry has been a very active member of the Testing in Python group and is quite active as an organizer for PyCon USA. You can get a feel for what projects interest him over on Github. Let’s take a few moments to get to know Terry better!

Can you tell us a little about yourself (hobbies, education, etc):

I am the Vice President of

Read the rest

Book ref: Project 4 (pg 95ff)

Python 2.7: Same

In this post you’re going to learn how to write code that Python ignores. Does that seem odd?
What would be the point of writing code and then deliberately not using it? It turns out that
there are two important times when you would prefer that Python did not execute your code:

  • comments, which you’ll be learning about in this post; and
  • debugging, which you’ll learn about later.

There are two … Read the rest

Hi Pythonistas, a new week, a new ‘bite’ of Python coding! This week we will get you to create a simple app to calculate the monetary cost of using an electrical device. Enjoy!… Read the rest

It’s review time again. Wow: challenge #20 already! We can’t believe we have worked through so many already. We also keep receiving amazing PRs, awesome!… Read the rest

Are the tests adequate?

Recently I described a solution to the problem of dividing a list into evenly sized chunks. It’s a simple enough problem with just two inputs: the list (or other sliceable container) xs and the number of chunks n. Nonetheless, there are traps to avoid and special cases to consider — … Read the rest