Show Menu
Cheatography

Python Cheat Sheet Cheat Sheet (DRAFT) by

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.ti­tle()
Changes the first letter of each word to uppercase Example: "Ada Lovela­ce"
str.up­per()
Changes the entire sting to uppercase
Example: "ADA LOVELA­CE"
str.lo­wer()
Changes the entire string to lowercase
Example: "ada lovelace
\n
Creates a new line
\t
Inserts a tab
string.rs­trip()
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 instru­ctions 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 inform­ation needed before the function can run
class ClassName:
Define a class
ClassName( Arguments)
Make inform­ation 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 instru­ctions for the class to run when it is started
ClassN­ame.Ob­jNa­me(­arg­uments)
Call an object of a class