You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
__name__# Module name or "__main__"__file__# Current file path__doc__# Module docstring
Comparison Operators
==# Equal!=# Not equal<# Less than># Greater than<=# Less or equal>=# Greater or equalis# Identity (same object)isnot# Not identityin# Membershipnotin# Not membership
Logical Operators
and# Both must be Trueor# At least one Truenot# Negation
String Methods Quick Reference
Method
Description
.upper()
Convert to uppercase
.lower()
Convert to lowercase
.strip()
Remove whitespace
.split()
Split into list
.join()
Join list into string
.replace()
Replace substring
.find()
Find substring index
.startswith()
Check prefix
.endswith()
Check suffix
.isalpha()
All alphabetic
.isdigit()
All digits
.isalnum()
Alphanumeric
File Modes
Mode
Description
"r"
Read (default)
"w"
Write (overwrites)
"a"
Append
"x"
Exclusive creation
"b"
Binary mode
"t"
Text mode (default)
"+"
Read and write
Common Exceptions
Exception
When It Occurs
ValueError
Wrong type of value
TypeError
Wrong type used
IndexError
List index out of range
KeyError
Dictionary key not found
FileNotFoundError
File doesn't exist
ZeroDivisionError
Division by zero
NameError
Variable not defined
AttributeError
Attribute doesn't exist
Tip: Keep this reference handy while learning Python! 📖