Max Min and Nested List in Python | Python programming | Codin India

Hello friends! Codin India here and in today's post we are going to learn Python's inbuilt functions that is

  • Min
  • Max
  • Nested List
So, Let us understand it one by one:- 

min():-

Python has an inbuilt function min() which finds the minimum value of the given list, tuples or something. It first calculates the biggest number one by one and provides the minimum value of the list.

Syntax:- min(array_name)

Code:-

list1 = [1,2,3,4,5,6]

print(min(list1))

Output:-

1

Explanation:- 

First we created list that has name list1 and then we created called Python's inbuilt function min() and print it.

Let us understand it by code:-

Python min function


max():-

Python has an inbuilt function min() which finds the minimum value of the given list, tuples or something. It first calculates the biggest number one by one and provides the minimum value of the list.

Syntax:- max(array_name)

Code:-

list1 = [1,2,3,4,5,6]

print(max(list1))

Output:-

6

Explanation:- 

First we created list that has name list1 and then we created called Python's inbuilt function max() and print it.

Let us understand it by code:-

python max function


All about Nested List in Python:-

Nested Means inside in something that means we have a list and in that List we have another List inside it. Like a small box inside a large box.


Like in the image shown above there is a small box inside a big box. That what nested means "inside in something".

In Python, we can nest list as well as tuples also. But in today's case we will discuss about List only because List and tuples are almost same.

Explanation:- First we create List and inside that list we will create another List. Syntax:- [[1,2,3],[4,5,6]]

In the syntax, we will create outer list and inside that list we created two list.

Let us understand it by code:-

what is nested list


Min and Max function on Nested List:- 

We can also implement min and max function on Nested List. We can create more nest. We will discuss it after this code.

Code:- 

min and max on nested list

Multiple Nest:-

We can nest multiple lists inside lists. Let us understand it by Code:-


In the above code, We will create a Outer List that is 2 inside lists and 3 lists insides internal lists as per picture. After that we have print the List and after that we print max value of the List.


I hope you would like the post and enjoyed.

Please Subscribe to our YouTube channel - Codin India

Comments