Python Functions - Class 11 & 12 (NCERT)
Class 11 - Input/Output Functions
- input() - Takes input from user.
- print() - Displays output.
Class 11 - Type Conversion Functions
- int() - Converts to integer.
- float() - Converts to float.
- str() - Converts to string.
- bool() - Converts to boolean.
Class 11 - Math Functions
- max(a, b, ...) - Returns the maximum value.
- min(a, b, ...) - Returns the minimum value.
- abs(x) - Returns absolute value.
- pow(x, y) - Returns x raised to y.
- round(x, n) - Rounds a number to n decimal places.
Class 11 - String Functions
- len(string) - Returns length.
- string.upper() - Converts to uppercase.
- string.lower() - Converts to lowercase.
- string.title() - Converts to title case.
- string.count(substring) - Counts occurrences.
- string.replace(old, new) - Replaces substring.
- string.find(substring) - Finds index of substring.
- string.strip() - Removes whitespace.
- string.isalpha() - Checks for alphabets only.
- string.isdigit() - Checks for digits only.
- string.isalnum() - Checks for alphanumeric.
- string.startswith(sub) - Checks if starts with sub.
- string.endswith(sub) - Checks if ends with sub.
Class 11 - List Functions
- len(list) - Length of list.
- list.append(x) - Adds x to end.
- list.insert(i, x) - Inserts x at index i.
- list.remove(x) - Removes first x.
- list.pop(i) - Removes and returns item at i.
- list.sort() - Sorts list.
- list.reverse() - Reverses list.
Class 12 - String Functions
- string.split() - Splits into list of words.
- string.join(list) - Joins list into string.
- string.partition(sep) - Splits at first occurrence.
- string.swapcase() - Swaps case of all letters.
- string.capitalize() - First character uppercase.
Class 12 - File Handling Functions
- open(filename, mode) - Opens a file.
- read() / readline() / readlines() - Reads data.
- write() / writelines() - Writes data.
- close() - Closes the file.
- seek(offset) - Moves cursor to offset.
- tell() - Returns current position of cursor.
Class 12 - Miscellaneous
- type() - Shows the type of variable.
- id() - Returns memory address of object.
- enumerate() - Useful in loops to get index.
- zip() - Combines multiple lists.
- range() - Generates sequence.