Cheatography
https://cheatography.com
Good cheat sheet for basic, but necessary things in python
This is a draft cheat sheet. It is a work in progress and is not finished yet.
String Operators
str.title() |
Changes the first letter of each word to uppercase Example: "Ada Lovelace" |
str.upper() |
Changes the entire sting to uppercase Example: "ADA LOVELACE" |
str.lower() |
Changes the entire string to lowercase Example: "ada lovelace |
\n |
Creates a new line |
\t |
Inserts a tab |
string.rstrip() |
Removes any whitespace |
str(data) |
changes almost any data type into a string |
Number Operator
+ |
Add |
- |
Subtract |
* |
Multiply |
/ |
Divide |
% |
Divde, but take the remainder as the answer |
int(data) |
Change almost any data type into an integer |
float(data) |
Change almost any data type into a float |
|
|
Functions and Classes
Function |
A set of instructions that can be run repeaditly by calling it |
Class |
A collection of functions that are attributes of one thing |
Objects |
The official names of the functions inside of classes |
def FuncName: |
Define a function |
FuncName(arguments) |
Make information needed before the function can run |
class ClassName: |
Define a class |
ClassName( Arguments) |
Make information needed before the class can run |
def ObjName (self, arguments) |
Creates an object inside a class that can be run when called |
def __init__ (self) |
Gives instructions for the class to run when it is started |
ClassName.ObjName(arguments) |
Call an object of a class |
|
|
|