Wednesday, December 19, 2012

Python 3.2 Tutorial 1: Hello World!

Python 3.2 Tutorial #1: Hello World!

Tutorial 1 contents: Code, and explanation for followed by useful information about Python in general.

# Python 3.2 Tutorial Part 1
# Brian R. H.

# the main method/function
def main():
print("Hello World!")

# Call to main function

How to Run on Your Computer!

  1. Download and Install Python version 3.2
    Python Download Page
  2. Create a text file
  3. Highlight the code and Copy (Ctrl+C) and Paste (Ctrl+V) it into the text file
  4. Correct indentation to look like the text on this page
  5. Save as ""
  6. Close the text file and locate the file that was created in the same directory as your original text file.
  7. Double left click the file and you should see a window open and close in an instant. This behavior of the file is correct so there is nothing to worry about, unless you really want to see it print "Hello World!" to a console window which I will show you how to do soon!

Use the Online IDE provided in the red link box to run Simply select Python on Online IDE and copy and paste the code and press execute!


In the file there are 5 specific elements to familiarize:
  1. # The pound symbol denotes a line comment
  2. def is a keyword used to define functions/methods
  3. " Anything surrounded by quotation marks is a string literal "
  4. () parenthesis often indicate functions such as main
  5. Header are comments placed at the top of a program with the file name, purpose of program, author of program, project name, ect.

About Python and Version 3.2

Although often thought of as a programming language, python is a scripting language! Scripting language or not, it would be challenging to find a software developer that had not used Python regardless of the version. Python 3.3.X is the most recent version of python available; however, version 2.4.X and 2.7.X are still the in wide use.

No comments: