0% found this document useful (0 votes)
4 views2 pages

Python Cheat Sheet Methods Functions

This document is a Python cheat sheet outlining built-in functions, list methods, string methods, and dictionary methods. Each section provides a brief description of the methods, their required and optional parameters, and the return values. It serves as a quick reference for Python programming.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

Python Cheat Sheet Methods Functions

This document is a Python cheat sheet outlining built-in functions, list methods, string methods, and dictionary methods. Each section provides a brief description of the methods, their required and optional parameters, and the return values. It serves as a quick reference for Python programming.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Python Cheat Sheet - Methods & Functions (Explained)

Built-in Functions
Function Required Optional Returns Description
Params Params
(Default)

print() *objects sep=' ', end='\ None Prints output to


n', flush=False console.

len(obj) obj - int Returns length


of an object.

range() stop OR start, step=1 range object Generates


stop (start=0) integer
sequence.

sum(iterable) iterable start=0 number Sums values in


iterable.

sorted(iterable) iterable key=None, list Returns new


reverse=False sorted list.

List Methods
Method Required Optional Returns Description
Params Params
(Default)

append(x) x - None Adds one


element to end.

extend(iterable iterable - None Adds multiple


) elements.

insert(i, x) i, x - None Inserts at index.

pop() - i=-1 element Removes and


returns
element.

remove(x) x - None Removes first


matching value.

sort() - key=None, None Sorts list in


reverse=False place.

String Methods
Method Required Optional Returns Description
Params Params
(Default)

strip() - chars=None str Removes


leading/trailing
spaces.

replace(old,ne old, new count=-1 str Replaces


w) substring.

split() - sep=None, list Splits string


maxsplit=-1 into list.

join(iterable) iterable - str Joins iterable


into string.

find(sub) sub start=0, int Returns index


end=len(str) or -1.

Dictionary Methods
Method Required Optional Returns Description
Params Params
(Default)

get(key) key default=None value Returns value


safely.

pop(key) key default(optiona value Removes and


l) returns value.

update(dict) dict - None Updates


dictionary
values.

keys() - - dict_keys Returns all


keys.

items() - - dict_items Returns key-


value pairs.

You might also like