Professional Documents
Culture Documents
def func1(1) :
return 1(-1) //-1 is the index value
func1(string)
print(func1(‘abcg’)
3) Print(sorted(string,key=func1))
TUPLES
Benefits:
Faster than list
Used as a keys in dictionaries //list can’t
tup1 = (1,2,3,4,5,6,7)
print(tup1[1:5])
SETS:
1. Store multiple items in the single variable.
Unindexed
Unordered
Mutable
Do not allow duplicates
Frozen sets are immutable
2.Enclosed in ([]) //list[]
//tuples()
MAPPING/DICTIONARIES
Unordered
Keys immutable & the values are mutable
{} //list[] ; tuple(); sets[()]; dictionaries{}
STRINGS
Letters,numbers,special characters
(‘abc’) or (“abc”) or (“””abc”””)
Strings immutable
Indexing and slicing operators.
Positive index starts from ‘0’and negative index ‘-1’ helps in accessing from the end.
DISTANCE METHOD/EUCLIDEAN DISTANCE (refer note for examples)
It is a distance measure that best can be explained as the length of a segment
connecting two points.
LOOPS
Repeated set of instructions.
TYPES
For loop
While loop
Nested loop
How to control loops or control statement in python?
Continue statement
Break statement
Pass statement