0% found this document useful (0 votes)
13 views4 pages

ALL Functions

The document provides a comprehensive overview of various functions available for strings, lists, dictionaries, and tuples in Python. Each section lists the function name, its purpose, and the format for usage. This serves as a quick reference guide for Python programming related to data structures.

Uploaded by

yuvalvermauv
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views4 pages

ALL Functions

The document provides a comprehensive overview of various functions available for strings, lists, dictionaries, and tuples in Python. Each section lists the function name, its purpose, and the format for usage. This serves as a quick reference guide for Python programming related to data structures.

Uploaded by

yuvalvermauv
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

FUNCTIONS IN STRINGS :

Name Function Format

len - tells length of a string


len(s1)
capitalize - returns copy with 1st chr capital
s1.capitalize()
count - returns no. of occurences of substring
s1.count('substring') returns 0 if not found
find - returns lowest index of a substring
s1.find('substring') returns -1 if not found
index - returns lowest index of a substring
s1.index('substring')
isalnum - True if string is alphabet or no.
s1.isalnum()
isalpha - True if string is alphabet
s1.isalpha()
isdigit - True if string is digit
s1.isdigit()
islower - True if all chr in string are lower case
s1.islower()
isupper - True if all chr in string are upper case
s1.isupper()
isspace - True if string has space
s1.isspace()
lower - returns copy converted to lower case
s1.lower()
upper - returns copy converted to upper case
s1.upper()
lstrip - returns copy with leading spaces removed
s1.lstrip()
rstrip - returns copy with trailing spaces removed
s1.rstrip()
strip - returns copy with both spaces removed
s1.strip()
startswith - True if string starts with substring
s1.startswith(substring)
endswith - True if string ends with substring
s1.endswith(substring)
title - returns copy with titled case
s1.title()
istitle - True if string is in titled case
s1.istitle()
replace - returns copy with old substring replaced by new
s1.replace(oldsubstring,newsubstring)
join - joins a string(s2) after each chr of other string(s1)
s2.join(s1)
split - returns list with containing split strings
s1.split()
partition - returns tuple with split strings (always 3) at seperator
s1.partition(seperator)
FUNCTIONS IN LISTS :

Name Function Format

len - tells length of a list


len(l1)
list - returns list created from seq type
list(seq)
index - returns lowest index of a substring
l1.index()
append - adds an item to the end of list
l1.append()
extend - adds multiple items at end of list
l1.extend([list])
insert - adds item to specific position
l1.insert(index,item)
pop - removes an item by index
l1.pop(index)
remove - remove a specific item
l1.remove()
del - remove multiple items from list using index del
l1[lower index:higher index]
clear - removes all items at once
l1.clear()
count - tells occurences of a particular item
l1.count()
reverse - reverses the whole list
l1.reverse()
sort - sorts items of list in ascending / descending order
l1.sort() / l1.sort(reverse=True)
sorted - sorts items in ascending / descending order
sorted(l1) / sorted(l1,reverse=True)
min - displays min element of list
min(l1)
max - displays max element of list
max(l1)
sum - displays sum of elements in a list
sum(l1)

FUNCTIONS IN DICTIONARIES :
Name Function Format

len - tells length of a dictionary


len(d1)
min - displays min key of dictionary
min(d1)
max - displays max key of dictionary
max(d1)
sum - displays sum of keys in a dictionary
sum(d1)
get - displays value of any particular key
d1.get(key)
items - displays a sequence of (key,value) in pairs
d1.items()
keys - displays all the keys in a dictionary in a list
d1.keys()
values - displays all the values in a dictionary in a list
d1.values()
copy - creates a copy of dictionary
d1.copy()
clear - removes everything from the dictionary
d1.clear()
sorted - sorts keys in ascending/descending order
sorted(d1)/sorted(d1,reverse=True)
popitem - removes and displays the last pair of dictionary
d1.popitem()
pop - removes any particular pair on basis on key entered
d1.pop()
fromkeys - creates a new dictionary of entered key and value
d1.fromkeys(key,value)
setdefault - inserts new key:value pair in already existing dictionary
d1.setdefault(key,value)
update - adds elements of other dict (d2) to main dict (d1)
d1.update(d2)

FUNCTIONS IN TUPLES :

Name Function Format

len - tells length of a tuple


len(t1)
min - displays min element of tuple
min(t1)
max - displays max element of tuple
max(t1)
sum - displays sum of elements in a tuple
sum(t1)
index - returns lowest index of a substring
t1.index()
count - tells occurences of a particular item
t1.count()
sorted - sorts items in ascending/descending order
sorted(t1)/sorted(t1,reverse=True)
sequence - creates tuple from any type
tuple()

You might also like