How to Find MIN and MAX Value in a Dictionary Using Python?

Practice Python effectively by following this step-by-step tutorial on how to get min and max values in a dictionary using Python. | ProjectPro

Python dictionaries are versatile data structures that efficiently store and retrieve key-value pairs. Often, you might need to find the minimum and maximum values within a dictionary. This tutorial helps you understand how to get the MAX and MIN values in a dictionary using Python. 

How to Find MAX Value in a Dictionary Using Python?

If you want to find the maximum value in a dictionary, you can utilize the max() function and a lambda function to specify the key based on which the maximum value should be determined. Check the example below to get a clear understanding - 

How to Get Key with MAX Value in a Dictionary Using Python? 

If we also need to retrieve the key associated with the maximum value in the dictionary, we can use a dictionary comprehension along with the max() function. Here’s how - 

How to Find MIN Value in a Dictionary Using Python? 

Similarly, finding the minimum value in a dictionary can be done using the min() function along with a lambda function or directly applying min()on the dictionary's values. For example:

How to Find Maximum and Minimum Values in a Matrix? 

Step 1 - Import the library

    import numpy as np

We have only imported numpy which is needed.

Step 2 - Setting up the Matrix

We have created a 4 x 4 matrix using arrays.

    matrix_101 = np.array([[10, 11, 12, 23],

                       [4, 5, 6, 25],

                       [7, 8, 9, 28],

                       [1, 2, 3, 41]])

Step 3 - Finding Maximum and Minimum Value

We can find the maximum and minimum values by using the function max and min respectively. We can also pass axes as a parameter which will help us to find maximum or minimum values of every row and column.

    print(np.max(matrix_101))

    print(); print(np.min(matrix_101))

    print(np.max(matrix_101, axis=0))

    print(); print(np.max(matrix_101, axis=1))

So the output comes as

41

1

[10 11 12 41]

[23 25 28 41]

Get Access to Python Projects Through ProjectPro! 

Gaining practical experience through real-world projects is paramount in mastering Python and its applications, especially in data science and big data. ProjectPro offers access to a diverse range of Python projects that enable learners to apply their knowledge in tangible ways. With ProjectPro, learning becomes more than just theory—it transforms into a hands-on experience, allowing individuals to experiment, troubleshoot, and ultimately deepen their understanding of Python. So why settle for mere comprehension when you can actively engage with Python concepts through ProjectPro? 

Download Materials

What Users are saying..

profile image

Anand Kumpatla

Sr Data Scientist @ Doubleslash Software Solutions Pvt Ltd
linkedin profile url

ProjectPro is a unique platform and helps many people in the industry to solve real-life problems with a step-by-step walkthrough of projects. A platform with some fantastic resources to gain... Read More

Relevant Projects

Learn How to Build a Linear Regression Model in PyTorch
In this Machine Learning Project, you will learn how to build a simple linear regression model in PyTorch to predict the number of days subscribed.

Ecommerce product reviews - Pairwise ranking and sentiment analysis
This project analyzes a dataset containing ecommerce product reviews. The goal is to use machine learning models to perform sentiment analysis on product reviews and rank them based on relevance. Reviews play a key role in product recommendation systems.

MLOps Project on GCP using Kubeflow for Model Deployment
MLOps using Kubeflow on GCP - Build and deploy a deep learning model on Google Cloud Platform using Kubeflow pipelines in Python

Build an AI Chatbot from Scratch using Keras Sequential Model
In this NLP Project, you will learn how to build an AI Chatbot from Scratch using Keras Sequential Model.

Demand prediction of driver availability using multistep time series analysis
In this supervised learning machine learning project, you will predict the availability of a driver in a specific area by using multi step time series analysis.

Forecasting Business KPI's with Tensorflow and Python
In this machine learning project, you will use the video clip of an IPL match played between CSK and RCB to forecast key performance indicators like the number of appearances of a brand logo, the frames, and the shortest and longest area percentage in the video.

Time Series Classification Project for Elevator Failure Prediction
In this Time Series Project, you will predict the failure of elevators using IoT sensor data as a time series classification machine learning problem.

Build Piecewise and Spline Regression Models in Python
In this Regression Project, you will learn how to build a piecewise and spline regression model from scratch in Python to predict the points scored by a sports team.

Build CNN for Image Colorization using Deep Transfer Learning
Image Processing Project -Train a model for colorization to make grayscale images colorful using convolutional autoencoders.

Deep Learning Project for Text Detection in Images using Python
CV2 Text Detection Code for Images using Python -Build a CRNN deep learning model to predict the single-line text in a given image.