Slicer in Strings:-
Or
Format
Operators
Identity Operators
Membership Operators
To print alternative numbers
Squaring a number with list comprehension
Tuple and String differentiate
We can make set from a list and we can initialize set with set() method
Sets Difference
Symmetric Difference
It will take the values from two sets which are not repeated in both sets
Subset of a set
We can define dictionary by defining the lists
In Dictionary we can get values using dict(name) or dict.get(name)
We can define the items, keys and values for a dictionary
Merging concept In Pandas
Pandas Series.isna() function detect missing values in the given series
object
Eg:
Use Index.dropna() function to remove all missing values from the given
Index
Eg:
inplace=True is used depending on if we want to make changes to the
original df or not.
all( ):
The all() function is an inbuilt function in Python which returns true if all the
elements of a given iterable( List, Dictionary, Tuple, set, etc) are True else it
returns False. It also returns False if the iterable object is empty.
any():
The any() function is an inbuilt function in Python which returns true if any of
the elements of a given iterable( List, Dictionary, Tuple, set, etc) are True
else it returns False.
dir():
dir() is a powerful inbuilt function in Python3, which returns list of the
attributes and methods of any object (say functions , modules, strings, lists,
dictionaries etc.)
divmod():
The divmod() method in python takes two numbers and returns a pair of
numbers consisting of their quotient and remainder.
Enumerate():
A lot of times when dealing with iterators, we also get a need to keep a count
of iterations. Python eases the programmers’ task by providing a built-in
function enumerate() for this task.
Enumerate() method adds a counter to an iterable and returns it in a form of
enumerate object. This enumerate object can then be used directly in for
loops or be converted into a list of tuples using list() method.
filter():
The filter() method filters the given sequence with the help of a function that
tests each element in the sequence to be true or not.
isinstance():
isinstance method uses if the object is an instance or subclass of classinfo
class
map():
The map() function executes a specified function for each item in an iterable.
The item is sent to the function as a parameter.
In Python, we can pass a variable number of arguments to a function using
special symbols. There are two special symbols:
Special Symbols Used for passing arguments:-
1.)*args (Non-Keyword Arguments)
2.)**kwargs (Keyword Arguments)
*args and **kwargs allow you to pass multiple arguments or keyword arguments to
a function
**kwargs works just like *args, but instead of accepting positional arguments it
accepts keyword (or named) arguments. Take the following example:
Lamda Functions:
In Python, an anonymous function means that a function is without a name.
As we already know that the def keyword is used to define a normal function
in Python. Similarly, the lambda keyword is used to define an anonymous
function in Python.