PowerShell vs Python Reference
September 16, 2020
Below is a reference between PowerShell and Python language syntax. Most of these examples where adapted from W3 schools Python tutorials. Is there something we have wrong or is missing? Please contact us.
Syntax
Arrays
PowerShell | Python | |
---|---|---|
Defining |
|
|
Access Element |
|
|
Length |
|
|
Adding |
|
|
Removing |
|
|
Removing by value |
|
|
Casting
PowerShell | Python | |
---|---|---|
Integers |
|
|
Floats |
|
|
Strings |
|
|
Classes
PowerShell | Python | |
---|---|---|
Definition |
|
|
Create Object |
|
|
Constructor |
|
|
Methods |
|
|
Conditions
PowerShell | Python | |
---|---|---|
If \ Else |
|
|
Comments
PowerShell | Python | |
---|---|---|
Single line |
|
|
Multiline |
|
|
Data Types
PowerShell | Python | |
---|---|---|
Get Type |
|
|
Dictionaries
PowerShell | Python | |
---|---|---|
Defining |
|
|
Accessing Elements |
|
|
Updating Elements |
|
|
Enumerating Keys |
|
|
Enumerating Values |
|
|
Check if key exists |
|
|
Adding items |
|
|
Functions
PowerShell | Python | |
---|---|---|
Definition |
|
|
Arguments |
|
|
Variable Arguments |
|
|
Named Arguments |
|
|
Default Values |
|
|
Return Values |
|
|
Lambdas
PowerShell | Python | |
---|---|---|
Lambda |
|
|
Loops
PowerShell | Python | |
---|---|---|
For |
|
|
While |
|
|
Break |
|
|
Continue |
|
|
Operators
PowerShell | Python | |
---|---|---|
Addition |
|
|
Subtraction |
|
|
Multiplication |
|
|
Division |
|
|
Modulus |
|
|
Floor |
|
|
Exponent |
|
|
Packages
PowerShell | Python | |
---|---|---|
Install |
|
|
Import |
|
|
List |
|
|
Strings
PowerShell | Python | |
---|---|---|
String |
|
|
Multiline |
|
|
Select Character |
|
|
Length |
|
|
Remove whitespace at front and back |
|
|
To Lowercase |
|
|
To Uppercase |
|
|
Replace |
|
|
Split |
|
|
Join |
|
|
Formatting |
|
|
Formatting by Index |
|
|
Formatting Strings |
|
|
Try \ Catch
PowerShell | Python | |
---|---|---|
|
|
Variables
PowerShell | Python | |
---|---|---|
|
| |
Global |
|
|