What are Literals in Python and explain about different Literals?

A literal in python source code represents a fixed value for primitive data types. There are 5 types of literals in Python- String literals A string literal is created by assigning some text enclosed in single of double quotes to a variable. To create multiline literals, assign the multiline text enclosed in triple quotes. E.g.,…

Read More

What are the common built-in data types in Python?

The common built-in data types in Python are: String A sequence of characters in called a string. They are declared within single or double-quotes. E.G., ‘Sana’, ‘she is going to the market’, etc. Set Sets are a collection of unique items that are not in order. e.g. {7, 6, 8}. Dictionary A dictionary stores values…

Read More

What are the common built-in data types in Python?

The common built-in data types in python are: Numbers They include integers, floating-point numbers, and complex numbers. e.g., 1, 2.4, 3 + 4j List An ordered sequences of items is called a list. The elements of a list belong to different data types. Eg. [5, ‘player’, 4.7]. Tuple It is also an ordered sequence of…

Read More

What are Dict and List Comprehensions in Python?

Dictionary and list comprehensions are just concise way to define dictionaries and lists. Example of list comprehension is: Var = [i for i in range (5)] The above code created a list as below- [0, 1, 2, 3, 4]  Example of dictionary comprehension is – X = [i : i + 2 for I in…

Read More

What are decorators in Python?

Decorators are used to add some design pattern to a function without changing its structure. Decorators generally are defined before the function they are enhancing. To apply a decorator, we first define the decorator function it is applied to and simply add the decorator function above the function it has to be applied to. For…

Read More

What are Python namespaces?

A namespace In Python refers to the name which is assigned to each object in Python. The objects are variables and functions. As each object is created, its name along with space (the address of the outer function in which the object is), gets created. The namespaces are maintained in Python like a dictionary where…

Read More

NumPy for Data Science – Part 5

The difference between copy and view Copy View Join & split function Join array – joining means putting contents of two or more array in a single array. hstack vs vstack The major difference is that np.hstack combines NumPy arrays horizontally and np.vstack combines arrays vertically. Split – splitting breaks one array into multiple. NumPy…

Read More

NumPy for Data Science – Part 4

Broadcasting NumPy Arrays The term broadcasting describes how NumPy treats arrays with different shapes during arithmetic operations. Subject to certain constraints, the smaller array is “broadcast” across the larger array in order that they have compatible shapes. NumPy operations are usually done on pairs of arrays on an element-by-element basis. Within the simplest case, the…

Read More

NumPy for Data Science – Part 3

Arithmetic Operations in NumPy Arrays In NumPy there are multiple functions which we can use to perform the arithmetic operation, we will be looking them one by one. The add() function can also be used to perform the same operation. The subtract() function can also be used to perform the same operation. The multiply() function…

Read More

NumPy for Data Science – Part 2

Create NumPy Arrays with Random Numbers Data Types in NumPy Arrays Shape and Reshaping In NumPy Arrays Shape of an Array The shape of an array is the number of elements in each dimension. Get the Shape of an Array NumPy arrays have an attribute called shape that returns a tuple with each index having the number…

Read More