Getting Started On Windows¶
Downloading Python¶
First, we need to download the software for the programming language that we want to code in, the language we’ll use is called Python.
Download from the following link: https://www.python.org/downloads/windows/
Opening Your Command Line Interface¶
In order to use a computer, we need some way of interacting with the computer’s functions and services. Luckily, every operating system (Mac, Windows, etc.) comes with user-interfaces. The one that you are probably most familiar with is the graphical user interface (GUI), which allows users to interact with files, folders, programs, etc. using graphical icons (e.g. Finder on Mac and My Computer on Windows). The other kind of user interface is called a command line interface (CLI). This differs from a GUI in that it is text-based, the user enters commands and executes them. The CLI is what programmers use to navigate their computer and run programs, so it is important to become familiar with it. Each operating system’s (OS’) CLI differs in name and some syntax, but that’s about it.
Window’s CLI is called Command Prompt, in order to open it, click Start, type ”cmd” in the search bar, and press Enter.
Writing Your First Program¶
There are many ways to program/write code.
We will provide information on two of the primary ways, using a notebook and using a text editor.
Online Notebook¶
For students with minimal experience, we recommend starting off with a notebook. A notebook allows users to input a chunk of code, and then run that chunk. This is great because it allows you to quickly find out whether or not your code works. As opposed to writing an entire program and then finding out it doesn’t work. We’ll use JupyterHub, which is an open-source web application for programming. All McMaster students can access the phys-ugrad (McMaster’s physics server) JupyterHub by:
Now you can create a new Python file by selecting ‘New’ and then ‘Python 3’. Now type the following line:
print(“Hello World!”)
Then hit Run to execute that line of code. If “Hello World” appears below the line of code, then you have successfully run the line of code! If nothing appears, then you probably made a mistake, which is the best way to become a better programmer. If you can’t figure out your error, feel free to post it on the Python Bootcamp course Discussion board on Avenue, or look it up on Google. Programmers spend a lot of time googling issues, it is a natural part of the process, and shouldn’t be looked down upon. So Google away!
Text Editor¶
Once we become comfortable with our coding skills, we will want to write more complicated programs that can be packaged and shared with others. The best way to do this is by writing a program in what is called a text editor. After writing, we save the program as a file with the .py extension, and then run the program in the command line. Lets download a text editor, Sublime Text is free and widely used. It can be dowloaded from the following link (make sure to choose the correct download for your OS):
Let’s write and run one of the simplest programs ever, just to get an idea of what the programming process looks like. Once downloaded, open Sublime Text and create a new file. Since we want to code in Python, make sure that the file has the .py extension after the name. Save it to any directory you want, but I recommend the Desktop for easy accessibility. In your empty file, type the following:
print(”Hello, World!”)
Then save the file. Now open your CLI and navigate to the directory that contains your file. Once there, use the appropriate command from the previous slide to execute the program. If ”Hello, World” appears in your CLI window, then you have successfully run the program!
Next Step¶
Now that you can write and run programs, feel free to go to:
- Python Basics: to learn Python syntax and test your knowledge with Avenue quizzes
- Python For Science: to explore Python templates that can be used for scientific data analysis