Home » Find the Biggest and Smallest of 3 numbers using lists in Python

Find the Biggest and Smallest of 3 numbers using lists in Python

Python Program to find the Biggest and Smallest of 3 numbers using lists

Hello everyone, welcome to Programming In Python! Here we discuss a simple Python program that finds the biggest and smallest of 3 numbers using lists. Here we use Python lists in this program.

Lists are the most commonly used data structure in Python, it is similar to array in most other programming languages.

Here we add the 3 numbers to the list and use max() and min() functions on it to find the biggest and smallest number respectively.

In the previous tutorials, we discussed finding the biggest and smallest number using functions: Link 

Master the basics of data analysis in Python. Expand your skillset by learning scientific computing with numpy.

Take the course on Introduction to Python on DataCamp here https://bit.ly/datacamp-intro-to-python

Program on GitHub

Biggest and Smallest of 3 numbers using lists – Code Visualization

Video :

You can also watch the video on YouTube here.

Task :

To find the smallest and most significant number out of the given 3 numbers.

Approach :

  • Read 3 input numbers using input() or raw_input().
  • Add these 3 numbers to list lst = [number1, number2, number3].
  • Using max() function to find the biggest number max(lst).
  • Finding the smallest number by using min() function min(lst).
  • Print the result.

Program on GitHub

Ad:
The Complete Python Bootcamp From Zero to Hero in Python – Enroll Now.
Udemy

Program :

number1 = int(input('Enter First number : '))
number2 = int(input('Enter Second number : '))
number3 = int(input('Enter Third number : '))

lst = [number1, number2, number3]

print("The largest of the 3 numbers is : ", max(lst))
print("The smallest of the 3 numbers is : ", min(lst))

 

Output :

Biggest and Smallest of 3 numbers using lists
Biggest and Smallest of 3 numbers using lists

Program on GitHub

Course Suggestion

Want to learn Python with strong fundamentals? If yes, I strongly suggest you take the course below.
Course: Fundamentals of Programming in Python

You can find more programs on using Python data type lists here, and also you can find out all the related posts on data types in Python here.

Online Python Compiler

Leave a Reply

Your email address will not be published. Required fields are marked *