Show Menu
Cheatography

Python - Automate Boring Stuff Cheat Sheet (DRAFT) by

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Basic math operators

**
Exponent
%
Modulus
//
Integer division
*
Multip­lic­ation
-
Subtra­ction
+
Addition
Also, use brackets to override the usual precedence

Variable name rules

1. Only one word allowed
2. Only numbers, letters and unders­cores allowed
3. Can't start with a number
 

Examples of literals

Integer literals
1, 2, 0, -1, -3234
Floating point literals
2.15, -1.25, 0.0
String literals
"­str­ing­", 'spam', ''

Comments

#
Marks the comment until EOL
 

String Concat­enation and Replic­ation

+
Concat­enates 2 strings
string * n
Replicates the string n times
Note that replic­ation needs integer as the right-hand value