Basics
Comments
Comments in Python start with a #
. There isn't a "true" mutli-line comment like /**/
in JavaScript.
haiku
Primitive Data Types
Python has four primitive data types
String
Integer
Float
Boolean
Everything is an object in Python
Variables
To define a variable in Python, type
In Python, variable names:
must start with a letter or underscore
cannot start with a number
contains only alpha-numeric characters and underscors
are case-sensitive
NOTE: The convention for multi-word variable names in Python is snake_case
Variables can be reassigned
Unlike JavaScript, you cannot declare a variable without initialising it with a value. The closest equivalent would be assigning None
String Operators
Arithmetic Operators
Compound Assignment Operators
Relational/Comparison Operators
In Python, you can "chain" conditions
Logical Operators
Last updated