Tuesday, October 30, 2012

PY-04: Solving Problems, Part 2

In the last post, I covered how decrementing functions can be useful for finding the solutions to simple problems, notably for finding a cubed root of a value, "x". However, it is important to note that while decrementing functions are sometimes the best call, they are not always so. Our next lesson covers another method, by the name of exhaustive enumeration.

Before we begin, please note that open and close brackets, i.e. "[" and "]" respectively, will contain raw code.

Exhaustive Enumeration


Exhaustive enumeration is a function for solving problems by which the computer exhausts possible options in a systematic way, so that it can find the correct one. This is what is known in the world of programming as a "brute force" tactic for solving problems, because of its straight-forward methods.

As computers are so adept at computing instructions swiftly, once outlandish ways to solve problems are now useful realities. An example of exhaustive enumeration in real life (albeit a watered-down version) would be finding which answers on a multiple-choice test question are not correct, and by process of elimination (exhaustion), we can come to the correct answer more easily.

Friday, October 26, 2012

PY-03: Solving Problems, Part 1

Programs are very useful for the purpose of solving problems. Many programmers know this potential of programs, and use it to their advantage. However, all is not so straight-forward in the world of programming and problem-solving; there are as many ways to go about finding a solution as there are stars in the sky (perhaps more!).

All in all, the method by which you code a program for finding the solution to a problem is up to the programmer -- you. That is why it is important to learn some of the basic ways by which one can arrive at a solution. Only after you understand these ways, can you move on to more complicated problem-solving.

Before we begin, please note that open and close brackets, i.e. "[" and "]" respectively, will contain raw code.

Decrementing Function

The first method is the decrementing function. A decrementing function starts with a non-negative value, which is decreased each time the program repeats the function's loop. The function will loop so long as the starting value is non-negative, but once it is equal to or less than 0, it will terminate.

Monday, October 22, 2012

PY-02: Elements of a Python Program, Part 2

Continuing from where I left off at the last post, "PY-01: Elements of a Python Program, Part 1", I will explain some more important elements that make up a Python program. These foundational elements MUST be learned, so pay attention!

Straight-line programs

These are the most basic of the programs that one could possibly code. A straight-line program is exactly what the name portrays -- a program that runs in a straight line, from start to finish. It does so by executing every command in order, one time. The alternatives to such programs would be one with conditionals which allow for options, or paths, for the program to follow; and branching programs, which are the limited cousins of conditionals.

Branching programs

This type of program is very similar to the straight-line program, with the exception that there are different paths available to choose from. When the program reaches a spot in the code where there are multiple options to choose from, we say it's branching off (like tree branches). Unfortunately, this means we have to manually code every single path it can take, and that it is bogged down by the size of data evaluated.


The conditional is huge in programming. Without it, we would have to program each and every possible variation that we could think of (and even then, we'd end up missing a ton of possibilities!). Not to mention, the program would be tedious and long. With a conditional, however, we can write a succinct piece of code that allows the program to execute that code for all possibilities.

Such conditionals are "if", "else", and "elif". They may not make much sense right now, but they will soon, trust me.


A looping construct is a piece of code that allows for expressions to be executed more than once. This is done by utilizing conditionals that redirect the program back to the beginning when certain conditions are met (usually, when trying to find a specific answer using a program, these "certain conditions" are when the answer has not been found). Loops need to have an end, or else they run until they crash.

Print command

The print command is a piece of code that will make expressions appear as they are in the shell. Here is an example of the print command:

>>>print "Text to be printed"
Text to be printed
Simple, right? This command is a tool that will be invaluable to your programming, so be prepared to use it often!

Next post, PY-03, I will go a bit more in-depth as to the use of programs for solving problems, utilizing most (if not all!) of the elements explained so far!

Saturday, October 20, 2012

PY-01: Elements of a Python Program, Part 1

This post is intended to teach the basic, core elements of a Python program, so that a foundation is built upon which more advanced teaching can take place. As with most programming languages, learning Python can be a tedious process, so prepare for a ton of reading and videos (and, hopefully, blog posts ;D).

IDLE (Integrated Development Environment)

The first, and arguably the most important, element of our Python program is IDLE -- or Integrated Development Enviroment (yeah, we know -- it should be IDE!). This is the program which combines a text editor, a debugger (for finding issues in the code), and a shell (which interprets the code).


This may come as no shock to you, but everything in Python is an object, even the code itself. This is so that everything can be referenced and called by other pieces of code and objects, allowing for complicated integration of objects calling other objects. It really is marvelous.

Every object has a particular type, which determines the very things that object can do, and how it is handled. Such types include the scalar (indivisible type), nonscalar (divisible), Boolean (true/false), or None (self-explanatory!).


Objects are inherently useless to programmers, since all they do is store data. While data is cool and all, it has to be strung together in expressions to truly harness their power. Expressions are sequences of objects and operators, much like sentences are sequences of words (this is intentionally convenient).


It would be hard to form legible expressions if objects didn't have custom-made names that we assigned them. A program might look more like a computer's instructions than a human's if they were all named "object0001," "object0002," etc. (or something like that).

This is where variables come in. Variables allow for the programmer (or program) to assign objects a particular name, that allows for the object to be called for use when the variable name of that object is called. This makes program look more like English than code, and allows for simpler programming.

This post is continued in PY-02, the next post on Python coding, where I will cover conditionals, straight-line programs, branching programs, loops, and a few commands that are almost necessary for any good program.

Wednesday, September 26, 2012

Understanding HTML and its Importance

In my last lesson on HTML, I covered some basic tags by which to code a webpage. Here's an example of a simple page code using tags from that post:

                <h1>Example page</h1>
                <br />
                <p> This is an example page. A clickable link can be found <a href="">here!</a>

This is incredibly simple, and would not pass as a real website today, but it does show the basic way in which HTML really works. Tags are nested inside other tags, but that's not all; while not quite necessary, I have used separate lines and indentation to make it easy to read our code.

I do this because anyone (including myself) who will inevitably come along to alter the code for any reason will have a tougher time deciphering it if it looks like this:

<html><h1>Example page</h1><br /><p>This is an example page. A clickable link can be found <a href="">here!</a></html>

While its certainly not impossible to read that particular piece of code, keep in mind that coding can easily span hundreds of lines, very quickly. Many decent pages have so many lines of code it would be a screwy task to even try counting them all!

So, the point is, keep your code clean and clear, for both our sake, and yours! 

Wednesday, September 19, 2012

The Basics of HTML, or How to Build a Page in One Post

The Basics of HTML
or How to Build a Page in One Post

With any luck, you will have found that subtitle to be quite appealing to your sense of impatience (or, perhaps more appropriately said, your sense of urgency). After all, the seemingly monolithic task of building a webpage would be excellent to have delegated to just one post. In just several hundred words, you can learn how to build a page from scratch!

Now, here comes the 'but.'

But, that webpage is going to be considerably low-quality. That's because even most poorly designed webpages required quite a bit of knowledge, coding, and debugging (rinse, lather, repeat). In the most basic languages, with a relatively small pool of different elements and attributes, there are only so many different interesting combinations available.

However, a foundation is necessary to learn anything, and this is especially true of coding. Many codes require foundational knowledge to even begin learning, and programming in general will sweep you up if you do not understand these foundations.

So we start with HTML, perhaps among the most basic of common coding languages available today. The best part about HTML, save its simplicity, is that it is everywhere. HTML makes up so much of what you see on the internet that I guarantee you wouldn't recognize anything if it were gone.

Wednesday, September 12, 2012

First post, and introductions

I suppose this is the most appropriate time to make an introductory post.

I am a college student in the United States with an interest in computer programming/coding. Currently, I am still in the process of learning this fascinating and useful subject, but I am already quite enthralled by its magnificence.

Computer programming is important to everyday life in so many ways that it has almost become too easy to forget about. As many people around the world now know at least some bits and pieces of computer programming and/or code, appreciation for this integral facet of science has exploded, creating an exponential increase in interest over time.