Python is a powerful programming language known for its flexibility and power. However, it's not well known in the general public despite it being an excellent starting point for beginners. Instead, they usually start with Visual Basic, which is unfortunate because Visual Basic teaches too much of the of "visual" aspects of programming instead of the logic based part necessary to allow one's mind to think effectively.
There is an awesome feature in Python: the IDLE (Integrated DeveLopment Environment) application, which allows a quick and easy way to write test code or algorithms. Start Python by opening pythonw.exe which opens the IDLE application. Next, go to File, New; this will open a blank file. Get into the habit of saving often by saving now as "Hello.py".
With this blank file, we will create the simple "hello world" program. Simply type "print 'hello world'" and press F5. This will compile and execute the code which should display "hello world". There! You've created your very first program in Python.
Thinking Abstractly
The most important thing in programming is to be able think like a computer. Remember: computers don't make mistakes, humans do. So if the program has a bug, it's not the code because the code did exactly what it was programmed to do. You simply need to change it so it does what you want it to do; obviously, if you're able to think like a computer, you will have less errors.
Functions and Variables
There are many different types of variables in programming. Most languages, however, makes it rather difficult to have different types of variables to interact with each other. For example, a string is basically a line of text; an integer would be something like 5. In Java, you would have to call the integer class's method in order to change an integer into a string (or vice versa) whereas in Python, you simply have to say "str(5)", which will return "5". The quotes represent strings. If you recall in mathematics that functions are in the form of f(x), you can think of programming as the same. You put something in the function and you get something in return; in math, if you define f(x) = 5x, then if x is 2, then f(2) returns 10. In str(5), it returns "5". Similarly, int("5") returns 5.
In Python, you can easily create a variable which can be used in a function similar to str() but do whatever you want it to do. The variable that goes in the parenthesis are called arguments. These arguments are then used in the function to be manipulated and returned for some new variable. For example, let's create a new function (type this out in IDLE):
def toString(argument):
return str(argument)
This code does exactly the same thing as str() because it returns the exact same function. Let's look at the two lines of code. The first line defines a new function; this means the computer creates a new function called "toString()". The second line tells the computer what will happen if the function is called or used. The keyword "return" means after using the function, it will return a value. So, in IDLE, after entering the function above, if you type:
toString(5)
This will print out 5. Of course, this is just a simple function; more advanced functions can be hundreds of lines long. Other variables that can be used in python include strings, floats, integers, and even custom variables called classes. However, that is more advanced and will not be covered here.
Published by cheeze
Love math which probably lead to my interest in programming; later started the violin which lead to music which is starting to overpower the programming side. College now. Yay. View profile
- Caring for a Ball PythonPerhaps you are looking into buying a Ball Python, or have recently acquired one, but are unsure of their characteristics and needs. This article will serve as a basic care guide for beginner Ball Python owners.
- The Pimsleur Method: Learn a New Language on Your Daily CommuteCD language programs are a convenient and easy way to learn a language. Pimsleur and Behind the Wheel offer great beginner programs. Which one is right for you?
- New Theories on Language Shed Light on the Nature of MusicTo understand the unique semantic content of music, we must first understand what language is and how it works in people, and consider music in the context of our discoveries about language.
- English as Global Language, TEFL InternationalFacts from notable sources about English being used as a global language as well as my views after taking a TEFL course. TEFL has taught me people around the world need to communicate more easily and TEFL can help ev...
- Computer Programming - Then and NowDescribes the history of computer programming language. The job of the computer programmer, and future career prospects.
- When Halloween Started and for What Purpose
- Getting Started in Fly Fishing
- The Basics of Paranormal Investigation: Get Started Ghost Hunting
- Photoshop Tutorial : How to Apply a Weather Effect to Your Text ?
- Tutorial: How to Sabotage Yourself
- Your First Python Application: Installing Python and Writing Code
- Photoshop Tutorial: Changing the Color Tone of Your Photos



