In my first month of learning python, I wrote a simple guess the number game. It did not include exception handling, was not pep8 compliant, and was organized somewhat poorly. It also needed updating because it used what I like to call "C Print Formatting," which used to be correct ...read more
I do not use dictionaries very often. Friday, I was without internet all day, so I took the opportunity to play with dir() and help() to discover some dictionary properties. My short-lived obsession with Draw Something on the iPhone has gotten me interested in anagrams (kicked the habit by reading ...read more
Strings, lists, tuples, integers, float, dictionaries, and sets are all types of python objects with different properties and uses. When using an object in a program or in your terminal, your session assigns an Id to access the computer's memory. The Id will be unique each session and on ...read more
Probably the most popular, I mean cult inspiring, computer programming book of all time. This book created a movement circa the year 2000. All the major universities that prided themselves on producing technical talent adopted this textbook into their curriculum. It began as a Scheme and Intro to Programming course ...read more
During my first month of learning python, I wrote a game to guess a number between 1 and 20 with six attempts. This simple game is good practice for a beginner. A better written and more advanced version can be found at http://housewifehacker.com/intermediate-guess-number-python-game.html. This example is ...read more
The built in math functions in Python use binary approximations, giving some funky results when dealing with numbers containing decimals:
>>> .1 + .2 0.30000000000000004 >>> round(100.00 / 3.000, 4) 33.333300000000001
One way to appropriately find the sum of decimals is to use stringsread more
>>> str(.1 + .2) '0.3 ...
Today I discovered the map function in Python. Map causes some simple for loops to be verbose and unnecessary. Let's look at how to change a list of integers to a list of strings. First we'll use a for loop:read more
>>> list = [1, 2, 3, 4, 5] >>> index = 0 ...
« Page 2 / 3 »