All Functions Class 12 Computer Science PDF by NItin Paliwal
All Functions Class 12 Computer Science PDF by NItin Paliwal
General Built-in Func ons update(other): Updates the dic onary with key-value pairs from another
abs(x): Returns the absolute (non-nega ve) value of x. dic onary.
divmod(x, y): Returns a tuple with the quo ent and remainder when x is clear(): Removes all items from the dic onary.
divided by y. fromkeys(seq, value): Creates a new dic onary with keys from seq, each
pow(x, y[, z]): Returns x raised to the power y. If z is given, computes (x^y) set to value.
mod z. copy(): Returns a shallow copy of the dic onary.
sum(iterable, start=0): Sums all items in an iterable, op onally star ng pop(key): Removes key and returns its value.
from a specified value. popitem(): Removes and returns an arbitrary key-value pair.
len(s): Returns the number of items (or characters) in an object, such as a setdefault(key, default): Returns the value of key if it exists; otherwise
string, list, or tuple. inserts key with default.
input(prompt): Reads a line of input (as a string) from the user. sorted(dict): When applied to a dic onary, returns a sorted list of its keys.
print(objects): Outputs the given objects to standard output.
type(object): Returns the type of the provided object. File Handling Func ons/Methods
list(iterable): Converts an iterable (like a string or tuple) into a list. Text Files
tuple(iterable): Converts an iterable into a tuple. open(filename, mode): Opens a file with the specified mode (e.g., "r",
str(object): Converts an object into its string representa on. "w", "a", etc.).
int(object): Converts an object to an integer, if possible. read(): Reads the en re contents of a text file.
float(object): Converts an object to a floa ng-point number. readline(): Reads one line from a text file.
sorted(iterable, key=None, reverse=False): Returns a new sorted list from readlines(): Reads all lines of a text file into a list.
the items in the iterable. write(string): Writes a string to a text file.
range(start, stop[, step]): Generates a sequence of numbers from start up writelines(list): Writes a list of strings to a text file.
to (but not including) stop. seek(offset): Moves the file pointer to a specified loca on.
dict(): Creates a new dic onary (also used for type conversion). tell(): Returns the current posi on of the file pointer.
close(): Closes the file.
String Methods Binary Files
capitalize(): Capitalizes the first character and lowercases the rest of the open(filename, mode): Opens a file in binary mode (e.g., "rb", "wb", etc.).
string. pickle.dump(obj, file): Serializes an object and writes it to a binary file.
tle(): Converts the first le er of each word to uppercase. pickle.load(file): Reads a serialized object from a binary file.
lower(): Converts all characters in the string to lowercase. CSV Files (using the csv module)
upper(): Converts all characters in the string to uppercase. csv.writer(file): Creates a writer object for CSV files.
strip(): Removes both leading and trailing whitespace. writerow(row): Writes a single row to a CSV file.
lstrip(): Removes leading whitespace. writerows(rows): Writes mul ple rows to a CSV file.
rstrip(): Removes trailing whitespace. csv.reader(file): Creates a reader object for CSV files.
split(sep): Splits the string into a list of substrings using the given
separator. Module Func ons
join(iterable): Concatenates an iterable of strings, inser ng the original Math Module
string between elements. sqrt(x): Returns the square root of x.
replace(old, new): Replaces all occurrences of a substring with a new ceil(x): Returns the smallest integer greater than or equal to x.
substring. floor(x): Returns the largest integer less than or equal to x.
find(sub): Returns the lowest index where the substring sub is found; pow(x, y): (Math version) Returns x raised to the power y as a float.
returns –1 if not found. fabs(x): Returns the absolute value of x as a float.
index(sub): Returns the first index where sub occurs (raises an error if not sin(x): Returns the sine of x (with x in radians).
found). cos(x): Returns the cosine of x.
count(sub): Returns the number of non-overlapping occurrences of a tan(x): Returns the tangent of x.
substring. Random Module
startswith(prefix): Checks if the string begins with the specified prefix. random(): Returns a random floa ng-point number in the range [0, 1).
endswith(suffix): Checks if the string ends with the specified suffix. randint(a, b): Returns a random integer between a and b (inclusive).
par on(sep): Splits the string at the first occurrence of sep into a tuple randrange(start, stop, step): Returns a randomly selected element from
of three parts. the specified range. (b is exclusive)
Sta s cs Module
List/Tuple Methods mean(data): Returns the arithme c mean (average) of the data.
append(x): Adds an element x to the end of the list. median(data): Returns the median value of the data.
extend(iterable): Adds each element from an iterable to the end of the mode(data): Returns the most frequently occurring value in the data.
list.
insert(i, x): Inserts an element x at index i. Database Connec vity & SQL Func ons
remove(x): Removes the first occurrence of x from the list. Python Database Connec vity Func ons
pop([i]): Removes and returns the element at index i (defaults to the last connect(): Establishes a connec on to an SQL database.
element). cursor(): Returns a cursor object to execute SQL queries.
count(x): Returns the number of mes x appears in the list. execute(query): Executes a SQL query using the cursor.
index(x): Returns the index of the first occurrence of x. commit(): Commits the current transac on to the database.
reverse(): Reverses the order of the list in place. fetchone(): Retrieves the next row of a query result.
sort(): Sorts the list in place. fetchall(): Retrieves all remaining rows of a query result.
sorted(): Returns a new sorted list from the exis ng list. rowcount: An a ribute giving the number of rows affected by the last
min(list): Returns the smallest element (when used on numeric lists). query.
max(list): Returns the largest element. SQL Aggregate Func ons (used within SQL queries)
sum(list): Returns the sum of numeric elements in the list. max(): Returns the maximum value in a column or set.
min(): Returns the minimum value in a column or set.
Dic onary Methods avg(): Returns the average (mean) value.
keys(): Returns a view of all keys in the dic onary. sum(): Returns the total sum of values.
values(): Returns a view of all values in the dic onary. count(): Returns the number of rows or non-null values.
items(): Returns a view of key-value pairs as tuples.
get(key, default): Retrieves the value for key if present; otherwise returns
default.