BeginnersBook

  • Home
  • Java
    • Java OOPs
    • Java Collections
    • Java Examples
  • C
    • C Examples
  • C++
    • C++ Examples
  • DBMS
  • Computer Network
  • Python
    • Python Examples
  • More…
    • jQuery
    • Kotlin
    • WordPress
    • SEO
    • JSON
    • JSP
    • JSTL
    • Servlet
    • MongoDB
    • XML
    • Perl

Python Program to Find Largest among Three Numbers

By Chaitanya Singh | Filed Under: Python Examples

In this article, we will write a python program to find the largest number among the three input numbers. To understand the following program, you should have the knowledge of following python concepts:

  1. Python if..elif..else statement
  2. How to take input from user in Python

python program to find the largest number among the three input numbers

In the following python program, we are taking input from the user. User enters three numbers and program finds the largest among three numbers using if..elif..else statement. Here we are using float() function while taking input from the user so that we can accept the numbers in float values as well.

# Python program to find the largest among three numbers

# taking input from user
num1 = float(input("Enter 1st number: "))
num2 = float(input("Enter 2nd number: "))
num3 = float(input("Enter 3rd number: "))

if (num1 >= num2) and (num1 >= num3):
   lnum = num1
elif (num2 >= num1) and (num2 >= num3):
   lnum = num2
else:
   lnum = num3

print("The largest number among",num1,",",num2,"and",num3,"is: ",lnum)

Output:
Python Program to Find Largest among Three Numbers

Related Python examples:

  1. Python program to convert Celsius to Fahrenheit
  2. Python program to find sum of n natural numbers
  3. Python program to add digits of a number
  4. Python program to add subtract multiply and divide two numbers
  5. Python program to swap two numbers

Leave a Reply Cancel reply

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

Python Tutorial

Introduction

  • Python Tutorial
  • Python Introduction
  • Install Python
  • PyCharm IDE Installation
  • Python in PyCharm
  • Python Comments
  • Python Variables
  • Python Keywords & Identifiers
  • Python data types

Flow Control

  • Python If
  • Python if..else
  • Python if..elif..else
  • Python Nested If
  • Python for loop
  • Python while loop
  • Python break
  • Python continue
  • Python pass

Python Functions

  • Python Functions
  • Python Recursion

Python Datatypes

  • Python Numbers
  • Python List
  • Python Strings
  • Python Tuple
  • Python Dictionary
  • Python Set

Python OOPs

  • Python OOP
  • Python Class & Object
  • Python Constructors

Python Examples

  • Python Programs

Copyright © 2012 – 2022 BeginnersBook . Privacy Policy . Sitemap