Python Built-in Methods and Functions Reference

Last Updated on May 11, 2026 by Admin

IndexCategoryMethod / FunctionDescriptionExample
1String.upper()Converts text to uppercase“hello”.upper()
2String.lower()Converts text to lowercase“HELLO”.lower()
3String.title()Converts text to title case“hello world”.title()
4String.capitalize()Capitalises first character“python”.capitalize()
5String.casefold()Aggressive lowercase conversion“HELLO”.casefold()
6String.swapcase()Swaps uppercase/lowercase letters“PyThOn”.swapcase()
7String.strip()Removes whitespace from both ends” hi “.strip()
8String.lstrip()Removes whitespace from left side” hi”.lstrip()
9String.rstrip()Removes whitespace from right side“hi “.rstrip()
10String.replace()Replaces text“cat”.replace(“c”,”b”)
11String.split()Splits string into list“a,b,c”.split(“,”)
12String.rsplit()Splits from right side“a,b,c”.rsplit(“,”)
13String.splitlines()Splits by line breakstext.splitlines()
14String.join()Joins iterable into string“-“.join([“a”,”b”])
15String.find()Finds first occurrence index“hello”.find(“e”)
16String.rfind()Finds last occurrence index“hello”.rfind(“l”)
17String.index()Finds index or raises error“hello”.index(“e”)
18String.count()Counts occurrences“hello”.count(“l”)
19String.startswith()Checks starting text“file.txt”.startswith(“file”)
20String.endswith()Checks ending text“file.txt”.endswith(“.txt”)
21String.removeprefix()Removes prefix from start“unhappy”.removeprefix(“un”)
22String.removesuffix()Removes suffix from end“file.txt”.removesuffix(“.txt”)
23String.isdigit()Checks if digits only“123”.isdigit()
24String.isalpha()Checks if alphabetic“abc”.isalpha()
25String.isalnum()Checks if alphanumeric“abc123”.isalnum()
26String.isspace()Checks if whitespace only” “.isspace()
27String.islower()Checks if lowercase“abc”.islower()
28String.isupper()Checks if uppercase“ABC”.isupper()
29String.istitle()Checks if title case“Hello World”.istitle()
30String.center()Centers text“hi”.center(10)
31String.ljust()Left justifies text“hi”.ljust(10)
32String.rjust()Right justifies text“hi”.rjust(10)
33String.zfill()Pads with zeros“42”.zfill(5)
34String.encode()Encodes string to bytes“hello”.encode()
35String.format()Formats strings“{}”.format(5)
36List.append()Adds item to endnums.append(5)
37List.extend()Adds multiple itemsnums.extend([1,2])
38List.insert()Inserts item at indexnums.insert(0,99)
39List.remove()Removes first matching itemnums.remove(5)
40List.pop()Removes item by indexnums.pop()
41List.clear()Removes all itemsnums.clear()
42List.index()Finds item indexnums.index(5)
43List.count()Counts occurrencesnums.count(5)
44List.sort()Sorts listnums.sort()
45List.reverse()Reverses listnums.reverse()
46List.copy()Creates copy of listnums.copy()
47Dictionary.keys()Returns dictionary keysdata.keys()
48Dictionary.values()Returns dictionary valuesdata.values()
49Dictionary.items()Returns key-value pairsdata.items()
50Dictionary.get()Safely retrieves valuedata.get(“name”)
51Dictionary.pop()Removes key and valuedata.pop(“age”)
52Dictionary.popitem()Removes last inserted itemdata.popitem()
53Dictionary.update()Updates dictionarydata.update({…})
54Dictionary.setdefault()Returns key value or inserts defaultdata.setdefault(“x”,0)
55Dictionary.clear()Removes all itemsdata.clear()
56Dictionary.copy()Copies dictionarydata.copy()
57Set.add()Adds item to sets.add(5)
58Set.remove()Removes items.remove(5)
59Set.discard()Removes item safelys.discard(5)
60Set.pop()Removes arbitrary items.pop()
61Set.clear()Removes all itemss.clear()
62Set.union()Combines setsa.union(b)
63Set.intersection()Returns common elementsa.intersection(b)
64Set.difference()Returns differencesa.difference(b)
65Set.symmetric_difference()Returns non-common elementsa.symmetric_difference(b)
66Set.issubset()Checks subseta.issubset(b)
67Set.issuperset()Checks superseta.issuperset(b)
68Set.isdisjoint()Checks no common elementsa.isdisjoint(b)
69Set.copy()Copies seta.copy()
70Tuple.count()Counts occurrencest.count(5)
71Tuple.index()Finds item indext.index(5)
72File.read()Reads entire filefile.read()
73File.readline()Reads one linefile.readline()
74File.readlines()Reads all lines into listfile.readlines()
75File.write()Writes text to filefile.write(“Hello”)
76File.writelines()Writes multiple linesfile.writelines(lines)
77File.seek()Moves file pointerfile.seek(0)
78File.tell()Returns current positionfile.tell()
79File.flush()Flushes bufferfile.flush()
80File.close()Closes filefile.close()
81Built-in Functionprint()Displays outputprint(“Hello”)
82Built-in Functioninput()Accepts user inputinput(“Name: “)
83Built-in Functionlen()Returns length/countlen(“hello”)
84Built-in Functiontype()Returns datatypetype(5)
85Built-in Functionabs()Returns absolute valueabs(-5)
86Built-in Functionround()Rounds numberround(3.1415,2)
87Built-in Functionmax()Returns largest valuemax([1,2,3])
88Built-in Functionmin()Returns smallest valuemin([1,2,3])
89Built-in Functionsum()Adds values togethersum([1,2,3])
90Built-in Functionsorted()Returns sorted iterablesorted([3,1,2])
91Built-in Functionreversed()Returns reversed iteratorreversed([1,2,3])
92Built-in Functionenumerate()Adds index to iterableenumerate([“a”,”b”])
93Built-in Functionzip()Combines iterableszip(a,b)
94Built-in Functionrange()Generates sequencerange(5)
95Built-in Functionmap()Applies function to iterablemap(str,[1,2])
96Built-in Functionfilter()Filters iterablefilter(is_even,nums)
97Built-in Functionall()Checks if all are trueall([True,True])
98Built-in Functionany()Checks if any are trueany([False,True])
99Built-in Functionid()Returns object memory identityid(x)
100Built-in Functionhelp()Displays help informationhelp(str)
101Built-in Functiondir()Lists object attributes/methodsdir(str)
102Type Conversionint()Converts to integerint(“5”)
103Type Conversionfloat()Converts to floatfloat(“5.2”)
104Type Conversionstr()Converts to stringstr(5)
105Type Conversionbool()Converts to booleanbool(1)
106Type Conversionlist()Converts to listlist(“abc”)
107Type Conversiontuple()Converts to tupletuple([1,2])
108Type Conversionset()Converts to setset([1,1,2])
109Type Conversiondict()Converts to dictionarydict()
110Type Conversioncomplex()Converts to complex numbercomplex(2,3)

Similar Posts