Python Built-in Methods and Functions Reference
Last Updated on May 11, 2026 by Admin
| Index | Category | Method / Function | Description | Example |
|---|---|---|---|---|
| 1 | String | .upper() | Converts text to uppercase | “hello”.upper() |
| 2 | String | .lower() | Converts text to lowercase | “HELLO”.lower() |
| 3 | String | .title() | Converts text to title case | “hello world”.title() |
| 4 | String | .capitalize() | Capitalises first character | “python”.capitalize() |
| 5 | String | .casefold() | Aggressive lowercase conversion | “HELLO”.casefold() |
| 6 | String | .swapcase() | Swaps uppercase/lowercase letters | “PyThOn”.swapcase() |
| 7 | String | .strip() | Removes whitespace from both ends | ” hi “.strip() |
| 8 | String | .lstrip() | Removes whitespace from left side | ” hi”.lstrip() |
| 9 | String | .rstrip() | Removes whitespace from right side | “hi “.rstrip() |
| 10 | String | .replace() | Replaces text | “cat”.replace(“c”,”b”) |
| 11 | String | .split() | Splits string into list | “a,b,c”.split(“,”) |
| 12 | String | .rsplit() | Splits from right side | “a,b,c”.rsplit(“,”) |
| 13 | String | .splitlines() | Splits by line breaks | text.splitlines() |
| 14 | String | .join() | Joins iterable into string | “-“.join([“a”,”b”]) |
| 15 | String | .find() | Finds first occurrence index | “hello”.find(“e”) |
| 16 | String | .rfind() | Finds last occurrence index | “hello”.rfind(“l”) |
| 17 | String | .index() | Finds index or raises error | “hello”.index(“e”) |
| 18 | String | .count() | Counts occurrences | “hello”.count(“l”) |
| 19 | String | .startswith() | Checks starting text | “file.txt”.startswith(“file”) |
| 20 | String | .endswith() | Checks ending text | “file.txt”.endswith(“.txt”) |
| 21 | String | .removeprefix() | Removes prefix from start | “unhappy”.removeprefix(“un”) |
| 22 | String | .removesuffix() | Removes suffix from end | “file.txt”.removesuffix(“.txt”) |
| 23 | String | .isdigit() | Checks if digits only | “123”.isdigit() |
| 24 | String | .isalpha() | Checks if alphabetic | “abc”.isalpha() |
| 25 | String | .isalnum() | Checks if alphanumeric | “abc123”.isalnum() |
| 26 | String | .isspace() | Checks if whitespace only | ” “.isspace() |
| 27 | String | .islower() | Checks if lowercase | “abc”.islower() |
| 28 | String | .isupper() | Checks if uppercase | “ABC”.isupper() |
| 29 | String | .istitle() | Checks if title case | “Hello World”.istitle() |
| 30 | String | .center() | Centers text | “hi”.center(10) |
| 31 | String | .ljust() | Left justifies text | “hi”.ljust(10) |
| 32 | String | .rjust() | Right justifies text | “hi”.rjust(10) |
| 33 | String | .zfill() | Pads with zeros | “42”.zfill(5) |
| 34 | String | .encode() | Encodes string to bytes | “hello”.encode() |
| 35 | String | .format() | Formats strings | “{}”.format(5) |
| 36 | List | .append() | Adds item to end | nums.append(5) |
| 37 | List | .extend() | Adds multiple items | nums.extend([1,2]) |
| 38 | List | .insert() | Inserts item at index | nums.insert(0,99) |
| 39 | List | .remove() | Removes first matching item | nums.remove(5) |
| 40 | List | .pop() | Removes item by index | nums.pop() |
| 41 | List | .clear() | Removes all items | nums.clear() |
| 42 | List | .index() | Finds item index | nums.index(5) |
| 43 | List | .count() | Counts occurrences | nums.count(5) |
| 44 | List | .sort() | Sorts list | nums.sort() |
| 45 | List | .reverse() | Reverses list | nums.reverse() |
| 46 | List | .copy() | Creates copy of list | nums.copy() |
| 47 | Dictionary | .keys() | Returns dictionary keys | data.keys() |
| 48 | Dictionary | .values() | Returns dictionary values | data.values() |
| 49 | Dictionary | .items() | Returns key-value pairs | data.items() |
| 50 | Dictionary | .get() | Safely retrieves value | data.get(“name”) |
| 51 | Dictionary | .pop() | Removes key and value | data.pop(“age”) |
| 52 | Dictionary | .popitem() | Removes last inserted item | data.popitem() |
| 53 | Dictionary | .update() | Updates dictionary | data.update({…}) |
| 54 | Dictionary | .setdefault() | Returns key value or inserts default | data.setdefault(“x”,0) |
| 55 | Dictionary | .clear() | Removes all items | data.clear() |
| 56 | Dictionary | .copy() | Copies dictionary | data.copy() |
| 57 | Set | .add() | Adds item to set | s.add(5) |
| 58 | Set | .remove() | Removes item | s.remove(5) |
| 59 | Set | .discard() | Removes item safely | s.discard(5) |
| 60 | Set | .pop() | Removes arbitrary item | s.pop() |
| 61 | Set | .clear() | Removes all items | s.clear() |
| 62 | Set | .union() | Combines sets | a.union(b) |
| 63 | Set | .intersection() | Returns common elements | a.intersection(b) |
| 64 | Set | .difference() | Returns differences | a.difference(b) |
| 65 | Set | .symmetric_difference() | Returns non-common elements | a.symmetric_difference(b) |
| 66 | Set | .issubset() | Checks subset | a.issubset(b) |
| 67 | Set | .issuperset() | Checks superset | a.issuperset(b) |
| 68 | Set | .isdisjoint() | Checks no common elements | a.isdisjoint(b) |
| 69 | Set | .copy() | Copies set | a.copy() |
| 70 | Tuple | .count() | Counts occurrences | t.count(5) |
| 71 | Tuple | .index() | Finds item index | t.index(5) |
| 72 | File | .read() | Reads entire file | file.read() |
| 73 | File | .readline() | Reads one line | file.readline() |
| 74 | File | .readlines() | Reads all lines into list | file.readlines() |
| 75 | File | .write() | Writes text to file | file.write(“Hello”) |
| 76 | File | .writelines() | Writes multiple lines | file.writelines(lines) |
| 77 | File | .seek() | Moves file pointer | file.seek(0) |
| 78 | File | .tell() | Returns current position | file.tell() |
| 79 | File | .flush() | Flushes buffer | file.flush() |
| 80 | File | .close() | Closes file | file.close() |
| 81 | Built-in Function | print() | Displays output | print(“Hello”) |
| 82 | Built-in Function | input() | Accepts user input | input(“Name: “) |
| 83 | Built-in Function | len() | Returns length/count | len(“hello”) |
| 84 | Built-in Function | type() | Returns datatype | type(5) |
| 85 | Built-in Function | abs() | Returns absolute value | abs(-5) |
| 86 | Built-in Function | round() | Rounds number | round(3.1415,2) |
| 87 | Built-in Function | max() | Returns largest value | max([1,2,3]) |
| 88 | Built-in Function | min() | Returns smallest value | min([1,2,3]) |
| 89 | Built-in Function | sum() | Adds values together | sum([1,2,3]) |
| 90 | Built-in Function | sorted() | Returns sorted iterable | sorted([3,1,2]) |
| 91 | Built-in Function | reversed() | Returns reversed iterator | reversed([1,2,3]) |
| 92 | Built-in Function | enumerate() | Adds index to iterable | enumerate([“a”,”b”]) |
| 93 | Built-in Function | zip() | Combines iterables | zip(a,b) |
| 94 | Built-in Function | range() | Generates sequence | range(5) |
| 95 | Built-in Function | map() | Applies function to iterable | map(str,[1,2]) |
| 96 | Built-in Function | filter() | Filters iterable | filter(is_even,nums) |
| 97 | Built-in Function | all() | Checks if all are true | all([True,True]) |
| 98 | Built-in Function | any() | Checks if any are true | any([False,True]) |
| 99 | Built-in Function | id() | Returns object memory identity | id(x) |
| 100 | Built-in Function | help() | Displays help information | help(str) |
| 101 | Built-in Function | dir() | Lists object attributes/methods | dir(str) |
| 102 | Type Conversion | int() | Converts to integer | int(“5”) |
| 103 | Type Conversion | float() | Converts to float | float(“5.2”) |
| 104 | Type Conversion | str() | Converts to string | str(5) |
| 105 | Type Conversion | bool() | Converts to boolean | bool(1) |
| 106 | Type Conversion | list() | Converts to list | list(“abc”) |
| 107 | Type Conversion | tuple() | Converts to tuple | tuple([1,2]) |
| 108 | Type Conversion | set() | Converts to set | set([1,1,2]) |
| 109 | Type Conversion | dict() | Converts to dictionary | dict() |
| 110 | Type Conversion | complex() | Converts to complex number | complex(2,3) |