The pracitce file is in main.py
round
functionabs
function
len()
cpapitalize() | only the first letter
upper()
find()
replace()
to reverse slicing reverse, [::-1]
range(start, end), range(value)
keys can hold only immutable datatypes link int, str,tuple ... but not list
dictionary methods, .get(key) or .get(key, default_Value)
.values()
.items()
.clear()
.copy()
.pop() or popitem()
.update({key: value})
dictionary
list
tuples: like as list but immutable, so it's much faster than list
set: one_set.difference(other_set), difference_update(), .discard(), .difference_update(), .intersection() or &, .isdisjoint(), .issuperset(), .issubset(), .union() or | .
** short-circuiting ** mean the stoppage of execution of boolean operation if the truth value of expression has been determined already.
iterable - list, dictionary, tuple, set, string
iterated - one by one check each item in the collection
.items(): to access key and value for dictionary in for loop
.values(): to print out only values of a dictionary
.keys(): only key
range(): in for loop
enumerate(): to list index with value in for loop
break: break out of the loop.
continue: means back to the loop don't care about the other program left in a function. print nothing.
pass: pass to the next ... at least fill something in a loop if nothing is there in a loop
print(value, end=)
to do action in our code.
DRY(don't repeat your self)
parameter vs argument
positional arguments
default parameter and keyword arguments
return
docstrings description of the function, help(func), print(func.doc)
argument and keyword argument(*args **kwargs)
rule of orders: params, *args, default parameters, **kwargs
Scope inside a function varables are local variables
global key word
nonlocal key word
Mutable | Immutable |
---|---|
List | Set |
- | Dictionary(key) |
- | - |
- | String |
class
@classmethod and @staticmethod
4 pillars of OOP
encapsulation: package
abstraction: private & public
inheritance
polymorphism
dunder mehtod
MRO method resolution order
map()
filter()
zip()
reduce()
lambda expression
list comprehension
set and dictionary comprehension
- Python basics I
- Python basics II
- Advanced oop
- Advanced Functional programming
- Advanced