Largest Among Three Values - Python Programming Exercise

In this exercise, you will develop a Python program that prompts the user to input three numbers and then determines and displays the largest one. This task introduces you to the use of conditional statements and comparison operators in Python, helping you understand how to evaluate and compare multiple values effectively. By completing this exercise, you will enhance your ability to work with user input, implement decision-making logic, and solve real-world problems in Python. Identifying the largest number among a set of inputs is a common programming challenge, making this exercise an essential step in strengthening your foundational Python programming skills.

 Category

Mastering Flow Control

 Exercise

Largest Among Three Values

 Objective

Develop a Python program that asks the user to input three numbers and then displays the largest one.

 Example Python Exercise

 Copy Python Code
# Prompt the user to enter the first number
num1 = float(input("Please enter the first number: "))

# Prompt the user to enter the second number
num2 = float(input("Please enter the second number: "))

# Prompt the user to enter the third number
num3 = float(input("Please enter the third number: "))

# Determine the largest number and display the result
largest = max(num1, num2, num3)
print(f"The largest number among {num1}, {num2}, and {num3} is {largest}")

 Output

Please enter the first number: 5
Please enter the second number: 8
Please enter the third number: 3
The largest number among 5.0, 8.0, and 3.0 is 8.0

 Share this Python Exercise

 More Python Programming Exercises of Mastering Flow Control

Explore our set of Python Programming Exercises! Specifically designed for beginners, these exercises will help you develop a solid understanding of the basics of Python. From variables and data types to control structures and simple functions, each exercise is crafted to challenge you incrementally as you build confidence in coding in Python.

  •  Loop Until Zero

    In this exercise, you will develop a Python program that prompts the user for a number "x" and calculates the result of 10 * x. The program will display...

  •  Loop Until Zero (Using While)

    In this exercise, you will develop a Python program that prompts the user for a number "x" and displays 10*x. This exercise is perfect for practicing user inpu...

  •  Loop with Counter

    In this exercise, you will develop a Python program that displays the numbers from 1 to 10 on the screen using a while loop. This task emphasizes the us...

  •  Multiplication Chart (Using While)

    In this exercise, you will develop a Python program that prompts the user to input a number and then displays its multiplication table using a while ...

  •  Descending Odd Values

    In this exercise, you will develop a Python program that displays the odd numbers from 15 to 7 in descending order using a while loop. This task ...

  •  Adding Values

    In this exercise, you will develop a Python program that prompts the user for an undetermined amount of numbers until the user enters 0. The program wil...