Tag Archive - hello world

Hello Python

As I talked about earlier, I am beginning to learn Python. I thought that this could be a good opportunity to document what I am learning and share my thoughts, experience and code.

To be totally cliche, I figured I would first demonstrate how to create the Hello World program in Python.

The most simplistic method to accomplish this is to simply print out the phrase:

print "Hello World!"

This looks almost exactly like PHP code expect you will notice there is no semicolon at the end of the statement. That is because Python does not use the semicolon to end a line.

Ok, let’s take this to the next level now. Let’s put this string inside a function that takes in a single parameter.

The function code looks like this:

def helloWorld(name):
  return "Hello " + name

So as you can see a function definition in Python begins with the word “def” followed by the function name (in this case helloWorld), and finally parameters in parenthesis with a colon at the end of the line.

Now this is where things get a little different. Instead of using regular block characters, we simply only indent the code to signify the code is apart of that block. It does not necessarily matter how many spaces or tabs you use in your code, however you must be consistent with how many spaces you use.

Now as you can see this function simply returns the word Hello with the name appended to it (with a space in between).

So now you can use the function in your code:

print helloWorld("Python")

That’s it. You can how say Hello World in Python.

PHP Hello World

Not be cliché, but I any book, tutorial or website discusses a programming language always begins with a program that simply displays the text “Hello World” on the screen and I intend to follow that tradition.

The process of writing text in PHP requires you to use either the “echo” of “print” function. There are some very minute differences between these two functions, but for these purposes, we will just say that they are interchangeable. If you really want to know the differences, there is an article that details this here.

Anyways, here is the hello world program for PHP.

<?
echo "Hello World";
?>

You could also use the print function and that would look like this:

<?
print "Hello World";
?>

You will notice that at the end of each line of code there is a semi-colon. Like many other languages, this is used at the end of most of the lines of code.

innerHTML in jQuery

Probably one of the more common things you use javascript for is to do simple replacement of text within a DIV. What you may not know is that you can use jQuery to make the command shorter (which makes it easier to type) and you actually can get more functionality than regular javascript.
Continue Reading…

jQuery Selector Tutorial

Today’s topic is going to be a basic look at the jQuery Selector system.  This is one of the most widely used feature of jQuery and is one of the features that will save you the most time from regular JavaScript.
Continue Reading…