Getting Started
How to check Python is installed on a Windows machine ?
open command prompt
type "py"
link - code.visualstudio.com/docs/python/python-tutorial#_prerequisites
link - learn.microsoft.com/en-us/training/browse/?terms=python
link - github.com/microsoft/c9-python-getting-started
link - realpython.com
link - python.org
Download Python
To install Python on Windows, go to the python.org download page and download Python 3.X.X.
Run the Python installer and accept all the defaults.
This will install Python in the following default folder:
folder - C:\Users\ "username" \AppData\Local\Programs\Python
Make sure you add Python to PATH. This allows you to use the python command in a terminal to run Python programs
This will also allow you easily install packages using the pip command from inside VS Code
If you only have one version of Python installed then adding Python to PATH makes sense.
VS Code Python Extension
Install the extension called "Python"
Select (File > New File > Python File)
type the following
print("hello world!")
select (File > Save As)
folder - C:\temp\python\Untitled-1.py
Select the triangle in the top right corner (Run Python File)
You see the following message appear in the Terminal window at the bottom
Virtual Environment
A python environment is a self contained folder that defines the corresponding python interpreter and any additional libraries/packages.
It is an isolated workspace for a specific project.
To see your current environment, look in the bottom right corner of VS Code for (.venv (3.12.7) )
Type the following code
print(f"Addition: 10 + 5 = {10 = 5}")
print(f"Division: 10/4 = {10/4:.2f}")
print(f"Integer Division : 10//4 = {10//4}")
The Debug.Console is the same as the Immediate Window in VBA
Start Debugging
Enter some code
Set a breakpoint
Press F5
Select "Python Debugger"
Select "Python File"
Wait for a few seconds
Press F10 to move to the next line
Press F5 to run until the end
You will see the Run and Debug pane on the left
This pane has four panels: Variables, Watch, Call Stack and Breakpoints.
To switch to your local environment
Run the following in the Terminal window
.venv\scripts\activate
To install the numpy package
pip install numpy
If you lose your environment
(Ctrl + Shift + P), select/type "Python Select Interpreter"
Type "cls" in the terminal window to clear window and move the cursor to the top
Add some comments, prefixing with #
# this is a comment
Ctrl + K + C - comment a line
Ctrl + K + U - uncomment a line
Indentation and White Space
White space is not ignored and is part of the syntax.
Blank lines are ignored, even when they are inside indented blocks.
Indentation
Indentation refers to the spaces at the beginning of a code line and is absolutely essential.
Where in other programming languages the indentation in code is for readability only, the indentation in Python is very important.
There are no curly brackets - indentation is used instead
Python uses indentation to indicate a block of code.
Python will give you an error if you skip the indentation.
Indentation - every indented block is indented by 4 spaces
def adjust_price(price: float, age: int) -> float:
if age > 60:
return price * .8
else:
return price
assert_equal(adjust_price(5.75, 63), 4.60)
assert_equal(adjust_price(5.75, 45), 5.75)
Vertical Alignment
res = function_name(var_one, var_two,
var_three, var_four)
Hanging Indent
res = function_name(
var_one, var_two,
var_three, var_four)
Additional Indentation
res = function_name(
var_one, var_two,
var_three, var_four)
print(var_one)
if(this_one
and that_one):
dosomething()
"and" is an operator and a keyword
Square Brackets
my_list = [
1, 2, 3,
4, 5, 6,
]
Parentheses
res = function_name(
'a', 'b', 'c',
)
Line Continuation Character
Implied line continuation is preferred to using the backslash character.
The backslash (\)
my_long_string = "This is some" \
"text on two lines"
© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited TopPrevNext