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

Gautam Vermani

Data Consultant at Confidential
linkedin profile url

Having worked in the field of Data Science, I wanted to explore how I can implement projects in other domains, So I thought of connecting with ProjectPro. A project that helped me absorb this topic... Read More

Relevant Projects

GCP MLOps Project to Deploy ARIMA Model using uWSGI Flask
Build an end-to-end MLOps Pipeline to deploy a Time Series ARIMA Model on GCP using uWSGI and Flask

Build an Image Segmentation Model using Amazon SageMaker
In this Machine Learning Project, you will learn to implement the UNet Architecture and build an Image Segmentation Model using Amazon SageMaker

Stock Price Prediction Project using LSTM and RNN
Learn how to predict stock prices using RNN and LSTM models. Understand deep learning concepts and apply them to real-world financial data for accurate forecasting.

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.

Build a Churn Prediction Model using Ensemble Learning
Learn how to build ensemble machine learning models like Random Forest, Adaboost, and Gradient Boosting for Customer Churn Prediction using Python

Machine Learning project for Retail Price Optimization
In this machine learning pricing project, we implement a retail price optimization algorithm using regression trees. This is one of the first steps to building a dynamic pricing model.

MLOps AWS Project on Topic Modeling using Gunicorn Flask
In this project we will see the end-to-end machine learning development process to design, build and manage reproducible, testable, and evolvable machine learning models by using AWS

Azure Deep Learning-Deploy RNN CNN models for TimeSeries
In this Azure MLOps Project, you will learn to perform docker-based deployment of RNN and CNN Models for Time Series Forecasting on Azure Cloud.

Recommender System Machine Learning Project for Beginners-3
Content Based Recommender System Project - Building a Content-Based Product Recommender App with Streamlit

Build Classification Algorithms for Digital Transformation[Banking]
Implement a machine learning approach using various classification techniques in Python to examine the digitalisation process of bank customers.