w7r.blogspot.com
Python 3.2 Tutorial #1: Hello World!
Tutorial 1 contents: Code, and explanation for HelloWorld.py followed by useful information about Python in general.
# HelloWorld.py
# Python 3.2 Tutorial Part 1
# w7r.blogspot.com
# Brian R. H.
# the main method/function
def main():
print("Hello World!")
# Call to main function
main()
How to Run HelloWorld.py on Your Computer!
- Download and Install Python version 3.2 Python Download Page
- Create a text file
- Highlight the HelloWorld.py code and Copy (Ctrl+C) and Paste (Ctrl+V) it into the text file
- Correct indentation to look like the text on this page
- Save as "HelloWorld.py"
- Close the text file and locate the HelloWorld.py file that was created in the same directory as your original text file.
- Double left click the HelloWorld.py 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 HelloWorld.py. Simply select Python on Online IDE and copy and paste the code and press execute!
About HelloWorld.py
In the file HelloWorld.py there are 5 specific elements to familiarize:
- # The pound symbol denotes a line comment
- def is a keyword used to define functions/methods
- " Anything surrounded by quotation marks is a string literal "
- () parenthesis often indicate functions such as main
- 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:
Post a Comment