Getting Started with Python Programming for Windows Users

Installation of Python

Setting up the Environment

Writing Your First Python Program


# File: Hello.py
def main():
  print ("Hello World!")

main()

Running Your First Program

Getting Started with Python Programming for Mac Users

Python comes bundled with Mac OS X. But the version that you have is quite likely an older version. Download the latest binary version of Python that runs on your version of Mac OS X and install it on your system.

If you have an older version of Python on your Mac do NOT uninstall it. You can have various versions of Python without any problems. To run the newer version as a separate command edit or create a .bash_profile in your home directory. You will be in your home directory when you open your terminal window. Add these two lines in it:

# set the path for Python 3
PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}"
export PATH

# set up an alias for the Python 3
alias python3='/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6'

You can add them by opening a text editor such as nano (you could also use vi or emacs if you are comfortable with those). Perform the following steps to edit your .bash_profile.

Type 'nano .bash_profile' to open the text editor
Add the lines from above by either copying and pasting or typing them in
Press 'ctrl+o' and then 'enter' to save the file
Press 'ctrl+x' to exit the text editor

Restart your computer. Now if you type python in any Terminal window the older version will be called upon and if you type python3 you will be using the newer verson. To check the version you are using, run this command:

python -V

python3 -V

Writing Your First Python Program

# File: Hello.py
def main():
  print ("Hello World!")

main()

Running Your First Program

Starting IDLE on Mac

Using IDLE on either Windows or Mac