
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Python program to find the maximum of three numbers
In this tutorial, we are going to write a program which finds the max amount from the three figures. We will have three number, and our goal is to find out the maximum number from those three numbers.
Let's see some sample test cases for better understanding.
Input: a, b, c = 2, 34, 4 Output: 34
Input: a, b, c = 25, 3, 12 Output: 25
Input: a, b, c = 5, 5, 5 Output: 5
Follow the below steps to find out the max number among three numbers.
Algorithm
1. Initialise three numbers a, b, c. 2. If a is higher than b and c then, print a. 3. Else if b is greater than c and a then, print b. 4. Else if c is greater than a and b then, print c. 5. Else print any number.
Let's see the code for the above algorithm.
Example
## initializing three numbers a, b, c = 2, 34, 4 ## writing conditions to find out max number ## condition for a if a > b and a > c: ## printing a print(f"Maximum is {a}") ## condition for b elif b > c and b > a: ## printing b print(f"Maximum is {b}") ## condition for c elif c > a and c > b: ## printing print(f"Maximum is {c}") ## equality case else: ## printing any number among three print(a)
Output
If you run the above program, you will get the following output.
Maximum is 34
Let's execute the code once again for different test case
Example
## initializing three numbers a, b, c = 5, 5, 5 ## writing conditions to find out max number ## condition for a if a > b and a > c: ## printing a print(f"Maximum is {a}") ## condition for b elif b > c and b > a: ## printing b print(f"Maximum is {b}") ## condition for c elif c > a and c > b: ## printing print(f"Maximum is {c}") ## equality case else: ## printing any number among three print(f"Maximum is {a}")
Output
If you run the above program, you will get the following output.
Maximum is 5
Conclusion
If you have any doubts regarding the tutorial, mention them in the comment section.
- Related Articles
- C# program to find the maximum of three numbers
- Java program to find maximum of three numbers
- Python program maximum of three.
- Program to find maximum sum of multiplied numbers in Python
- Program to find largest of three numbers - JavaScript
- Program to find maximum additive score by deleting numbers in Python
- Java Program to Find the Largest Among Three Numbers
- Swift Program to Find the Largest Among Three Numbers
- Kotlin Program to Find the Largest Among Three Numbers
- Haskell program to find the largest among three numbers
- Program to find the common ratio of three numbers in C++
- Program to find maximum difference of adjacent values after deleting k numbers in python
- 8085 program to find maximum and minimum of 10 numbers
- 8085 program to find maximum of two 8 bit numbers
- Maximum Product of Three Numbers in C++

Advertisements