How to find MIN, MAX in a Dictionary in python

This recipe helps you find MIN, MAX in a Dictionary in python

Recipe Objective

Statical analysis is very important part preprocessing. Have you tried to find minimum and maximum value in a dictionary?

So this is the recipe on how we can find MIN, MAX in a Dictionary.

Step 1 - Creating a dictionary

We have created a dictionary with different values. ages = {"John": 21, "Mike": 52, "Sarah": 12, "Bob": 43}

Step 2 - Finding minimum and maximum value

We have calculated minimum and maximum values of the dictionary. print("Maximum Value: "); print(max(zip(ages.values(), ages.keys()))) print("Minimum Value: "); print(min(zip(ages.values(), ages.keys()))) So the output comes as

Maximum Value: 
(52, "Mike")

Minimum Value: 
(12, "Sarah")

Download Materials


What Users are saying..

profile image

Abhinav Agarwal

Graduate Student at Northwestern University
linkedin profile url

I come from Northwestern University, which is ranked 9th in the US. Although the high-quality academics at school taught me all the basics I needed, obtaining practical experience was a challenge.... Read More

Relevant Projects

PyTorch Project to Build a LSTM Text Classification Model
In this PyTorch Project you will learn how to build an LSTM Text Classification model for Classifying the Reviews of an App .

Azure Text Analytics for Medical Search Engine Deployment
Microsoft Azure Project - Use Azure text analytics cognitive service to deploy a machine learning model into Azure Databricks

Build OCR from Scratch Python using YOLO and Tesseract
In this deep learning project, you will learn how to build your custom OCR (optical character recognition) from scratch by using Google Tesseract and YOLO to read the text from any images.

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 and Deploy Text-2-SQL LLM Using OpenAI and AWS
In this LLM project, you will learn to build a user-friendly web application that leverages Large Language Models (LLMs) to convert natural language queries into optimized SQL commands.

Linear Regression Model Project in Python for Beginners Part 1
Machine Learning Linear Regression Project in Python to build a simple linear regression model and master the fundamentals of regression for beginners.

MLOps Project to Build Search Relevancy Algorithm with SBERT
In this MLOps SBERT project you will learn to build and deploy an accurate and scalable search algorithm on AWS using SBERT and ANNOY to enhance search relevancy in news articles.

Classification Projects on Machine Learning for Beginners - 1
Classification ML Project for Beginners - A Hands-On Approach to Implementing Different Types of Classification Algorithms in Machine Learning for Predictive Modelling

Avocado Machine Learning Project Python for Price Prediction
In this ML Project, you will use the Avocado dataset to build a machine learning model to predict the average price of avocado which is continuous in nature based on region and varieties of avocado.

Many-to-One LSTM for Sentiment Analysis and Text Generation
In this LSTM Project , you will build develop a sentiment detection model using many-to-one LSTMs for accurate prediction of sentiment labels in airline text reviews. Additionally, we will also train many-to-one LSTMs on 'Alice's Adventures in Wonderland' to generate contextually relevant text.