0% found this document useful (0 votes)
73 views3 pages

Python Cheat Sheet

This document provides a cheat sheet overview of common Python methods and functions related to strings, files, sets, mappings, dates, times, arrays, and math. It includes brief descriptions and examples of built-in string methods like capitalize(), count(), find(), and split(). It also covers file methods like close(), read(), and write(). Methods for sets, mappings, and datetime objects are presented as well.

Uploaded by

Sunil Choudhary
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
73 views3 pages

Python Cheat Sheet

This document provides a cheat sheet overview of common Python methods and functions related to strings, files, sets, mappings, dates, times, arrays, and math. It includes brief descriptions and examples of built-in string methods like capitalize(), count(), find(), and split(). It also covers file methods like close(), read(), and write(). Methods for sets, mappings, and datetime objects are presented as well.

Uploaded by

Sunil Choudhary
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 3

10/05/2023, 18:01 Python Cheat Sheet | OverAPI.

com

OverAPI.com Python jQuery NodeJS PHP Java Ruby Javascript ActionScript CSS Express More » Search

Resource String File Set & Date Time


Online String Methods Methods Mapping Date Object
Official Website capitalize() close() replace((year, month, day))
PythonForBeginners.com center(width[, fillchar]) flush() Set Types timetuple()
count(sub[, start[, end]]) fileno() len(s) toordinal()
Download decode isatty() x in s weekday()()
Python Quick Reference Card [. encode([encoding[, errors]]) next() x not in s isoweekday()()
pdf] endswith(suffix[, start[, end]]) read([size]) isdisjoint(other) isocalendar()()
Python 2.6 Quick Reference expandtabs([tabsize]) readline([size]) issubset(others) isoformat()
find(sub[, start[, end]]) readlines([sizehint]) issuperset __str__()
Related format(*args, **kwargs) xreadlines() union(other...) ctime()
Django index(sub[, start[, end]]) seek(offset[, whence]) intersection(other, ...) strftime()
isalnum() tell() difference(other...)
isalpha() truncate([size]) symmetric_difference(other) Datetime Object
isdigit() write(str) copy() date()
islower() writelines(sequence) update() time()
Array isspace()
istitle() Attributes
intersection_update() timetz()
replace([year[, month[, day[, ho
difference_update()
Array Methods isupper() closed symmetric_difference_update() ur[, minute[, second[, microseco
append(x) join(iterable) encoding add(elem) nd[, tzinfo]]]]]]]])
buffer_info() ljust(width[, fillchar]) errors remove() astimezone(tz)
byteswap() lower() mode discard(elem) utcoffset()
count(x) lstrip([chars]) name pop() dst()
extend(iterable) partition(sep) newlines clear() tzname()
fromfile(f,n) replace(old, new[, count]) softspace timetuple()
fromlist(list) rfind(sub[, start[, end]]) Mapping Types utctimetuple()
fromstring(s) rindex(sub[, start[, end]]) toordinal()
rjust(width[, fillchar])
len(d)
fromunicode(s) weekday()
rpartition(sep) d[key] isoweekday()
index(x)
insert(i,x) rsplit([sep[, maxsplit]])
rstrip([chars])
Math d[key] = value
del d[key]
isocalendar()
isoformat()
pop([i])
remove(x) split([sep[, maxsplit]]) Number Theoretic key in d __str__()
reverse() splitlines([keepends]) ceil(x) key not in d ctime()
tofile(f) startswith(prefix[, start[, end]]) copysign(x,y) iter(d) strftime()
tolist() strip([chars]) fabs(x) clear()
tostring() swapcase factorial(x) copy() Time Object
tounicode() title() floor(x) fromkeys(seq[, value]) replace([hour[, minute[, second
translate(table[, deletechars]) fmod(x,y) get(key[, default]) [, microsecond[, tzinfo]]]]])
Indexes and Slices upper() frexp(x) has_key(key) isoformat()
zfill(width) fsum(iterable) items() __str__()
a=[0,1,2,3,4,5] isnumeric() isinf(x) iteritems() strftime()
len(a) 6 isdecimal() utcoffset()
isnan(x) iterkeys()
a[0] 0 dst()
ldexp(x,i) itervalues()
a[5] 5 modf() keys() tzname()
a[-1] 5 trunc() pop(key[, default])
a[-2] 4 popitem()

https://overapi.com/python 1/3
10/05/2023, 18:01 Python Cheat Sheet | OverAPI.com
a[1:] [1,2,3,4,5] Power and Logarithmic
OverAPI.com
a[:5] Python jQuery
[0,1,2,3,4] NodeJS Random
PHPJava Ruby Javascript
exp(x)ActionScript CSS Express
setdefault(key[, default])
More »
update([other]) Sys
a[:-2] [0,1,2,3] log(x[,base]) values
Functions Sys Variables
a[1:3] [1,2] log1p(x)
seed([x])
log10(x) argv
a[1:-1] [1,2,3,4] getstate() Command line args
pow(x,y)
b=a[:] Shallow copy of a setstate(state)
sqrt(x) builtin_module_names
jumpahead(n)
getrandbits(k)
OS Linked C modules
byteorder
Trigonometric Functions
randrange([start], stop[, step]) os Variables Native byte order
acos(x)
randint(a,b) altsep check_-interval
Class choice(seq)
shuffle(x[,random])
asin(x)
atan(x) Alternative sep Signal check frequency
atan2(y,x) curdir exec_prefix
Special Methods sample(population,k) Root directory
cos(x) Current dir string
__new__(cls) random() executable
uniform(a,b)
hypot(x,y) defpath
__lt__(self, other) sin(x) Default search path Name of executable
__init__(self, args) triangular(low,high,mode)
tan(x) devnull exitfunc
betavariate(alpha,beta)
__le__(self, other) expovariate(lambd) Path of null device Exit function name
__del__(self) Angular Conversion extsep modules
gammavariate(alpha,beta)
__gt__(self, other) degrees(x) Extension separator Loaded modules
gauss(mu,sigma)
__repr__(self) lognormvariate(mu,sigma)
radians(x) linesep path
Line separator Search path
__ge__(self, other) normalvariate(mu,sigma)
vonmisesvariate(mu,kappa)
Hyperbolic Functions name platform
__str__(self) acosh(x) Current platform
paretovariate(alpha) Name of OS
__eq__(self, other) asinh(x) stdin, stdout, stderr
weibullvariate(alpha,beta) pardir
__cmp__(self, other) atanh(x) Parent dir string File objects for I/O
__ne__(self, other) cosh(x) pathsep version_info
__index__(self) sinh(x) Python version info
__nonzero__(self) String tanh(x)
Patch separator
sep winver
__hash__(self) Version number
__getattr__(self, name) Formatting Constants
Path separator

__getattribute__(self, nam math.pi sys.argv


Formatting Operations The mathematical constant π = sys.argv[0] foo.py
e)
'd' 3.141592..., to available precisi sys.argv[1] bar
__setattr__(self, name, attr) Signed integer decimal. on.
__delattr__(self, name)
__call__(self, args, kwargs)
'i' math.e
The mathematical constant e =
Date sys.argv[2]
sys.argv[3]
-c
qux
Signed integer decimal.
'o' 2.718281..., to available precisi
on.
Formatting sys.argv[4] --h
Signed octal value.
'u' Date Formatting
Obsolete type – it is identical to %a
'd'. Abbreviated weekday (Sun)
'x' %A
Signed hexadecimal (lowercas Weekday (Sunday)
e). %b
'X' Abbreviated month name (Jan)
Signed hexadecimal (uppercas %B
e). Month name (January)
'e' %c
Floating point exponential forma Date and time
t (lowercase). %d

https://overapi.com/python 2/3
10/05/2023, 18:01 Python Cheat Sheet | OverAPI.com
'E' Day (leading zeros) (01 to 31)
OverAPI.com Python jQuery NodeJS PHPexponential
Floating point Java Rubyforma Javascript ActionScript CSS Express More
%H »
t (uppercase). 24 hour (leading zeros) (00 to 2
'f' 3)
Floating point decimal format. %I
'F' 12 hour (leading zeros) (01 to 1
Floating point decimal format. 2)
'g' %j
Floating point format. Uses low Day of year (001 to 366)
ercase exponential format if exp %m
onent is less than -4 or not less Month (01 to 12)
than precision, decimal format o %M
therwise. Minute (00 to 59)
'G' %p
Floating point format. Uses upp AM or PM
ercase exponential format if exp %S
onent is less than -4 or not less Second (00 to 61?)
than precision, decimal format o
therwise.
%U
Week number1 (00 to 53)
'c'
Single character (accepts integ
%w
er or single character string). Weekday2 (0 to 6)
'r' %W
String (converts any Python obj Week number3 (00 to 53)
ect using repr(). %x
's' Date
String (converts any Python obj %X
ect using str() Time
'%' %y
No argument is converted, resul Year without century (00 to 99)
ts in a '%' character in the resul %Y
t. Year (2008)
%Z
Time zone (GMT)
%%
A literal "%" character (%)

https://overapi.com/python 3/3

You might also like