smart and simple

Photo by XPS on Unsplash

In this article, we will see some functions related to linear algebra and more.

eye: It creates an identity matrix.


smart and simple

Photo by XPS on Unsplash

In a previous article, we have seen how we can create a numpy array manually.

In this article, we will see how we can create an array randomly, slicing of 2D array and functions related to array.

How to create an array randomly?

There are a lot of ways to create an array randomly.

  • randint: It returns random integers from start to end. (start is inclusive and the end is exclusive)


smart and simple

Photo by Alexandru Acea on Unsplash

Points which we are going to discuss in numpy articles are as follow:

  • What is numpy?
  • Functions in numpy
  • Relational operations on numpy
  • Image operations using numpy

__________________________________________________________________

Numpy stands for numeric python.

Numpy is like a list data structure but more powerful than the list.

First, we have to import the numpy library then we can create a numpy array.

import numpy as np

np is just a short name for numpy so that we can use np instead of numpy.


smart and simple

Photo by Sigmund on Unsplash

I hope you all are familiar with list, tuple, set, and dictionary in python.

In this article, we will see what is map, filter, and reduce in python.

Before that let’s see what is lambda function.

Normal function resides in memory for the lifetime of a program but what if we want to use a function for a single time, for that purpose there is a concept known as a lambda function.

It is a single line function and after execution, it gets deleted automatically from RAM. That’s why it is also known as an anonymous function.


smart and simple

Photo by Domenico Loia on Unsplash

In the last article, we have discussed the dictionary in python.

Now we will discuss functions in dictionaries.

Functions we are going to see:

  • fromkeys
  • pop
  • popitem
  • setdefault
  • update

________________________________________________________

let’s create a dictionary first

We can create a new dictionary using fromkeys() function with keys from iterable and values set to value.


smart and simple

Photo by Albuu Design de Álbuns on Unsplash

Dictionary is one of the most important data structure in python.

Dictionary is a mutable object which means we can add and delete values from it.

It is a collection of key:value pairs inside curly braces ( { } ).

d1 = { key1:value1, key2:value2, key3:value3 }


smart and simple

Photo by XPS on Unsplash

In this article, we will learn functions in the set.

Set is a mutable object which means we can add or delete elements from the set.

There are some special functions in the set.

  • union
  • intersection
  • difference
  • difference_update

and many more.

The operation we have implemented in the 10th standard on the set can be performed using these functions.

let’s see one by one


smart and simple

This is going to be a very interesting article related to the set in python.

Properties of set in python:

  • Unique elements
  • Fast in search
  • Unordered elements

__________________________________________________________

we can create set by placing elements inside curly braces( {} )

for example S1 = {10, 20, 30,40}

if we print S1, we will get output but that will not be in the same sequence as we have provided.


smart and simple

Photo by Headway on Unsplash

So, talking about tuple in python is a collection of items inside the round brackets.


smart and simple

Photo by Christopher Gower on Unsplash

List Comprehension

Well, now you all are very much familiar with lists in python and this will be the last article for the list.

Today we will see the list comprehension which is very interesting and will help us to save time while coding.

Let’s understand what it is.

suppose I have a list A = [2, 6, 8, 10] and I want a new list as B which will contain a square of elements that are present in list A

Vivek Nikam and Abhay Chaudhari

Smart and Simple Solutions.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store