Youngest Age of Three Program in Python


If the ages of Ram, Shyam and Ajay are input through the keyboard, write a program to determine the youngest of the three.

This program is a simple Python script that takes input of the ages of three individuals, Ram, Shyam, and Ajay. It then uses an if-else statement to compare the ages of the three individuals and determine which one is the youngest.

  • The program starts by taking input for the age of Ram, Shyam, and Ajay using the input() function. The input is then stored in variables age1, age2, and age3.
  • The program then uses an if-else statement to compare the ages of Ram, Shyam and Ajay. The first condition in the if-else statement checks whether the age of Ram is less than the age of Shyam and Ajay. If this condition is true, it means that Ram is the youngest and the program will print "The Youngest Age is Ram".
  • The second condition in the if-else statement checks whether the age of Shyam is less than the age of Ram and Ajay. If this condition is true, it means that Shyam is the youngest and the program will print "The Youngest Age is Shyam".
  • The last else statement will be executed if none of the above conditions are met, it means that Ajay is the youngest and the program will print "The Youngest Age is Ajay".

In summary, the program takes input of the ages of three individuals, compares their ages using an if-else statement, and determines which one is the youngest, it then prints the name of the youngest person.


Source Code

age1 = int(input("Enter the Age of Ram :"))
age2 = int(input("Enter the Age of Shyam :"))
age3 = int(input("Enter the Age of Ajay :"))
if(age1<age2 and age1<age3):
	print("The Youngest Age is Ram")
elif(age2<age1 and age2<age3):
	print("The Youngest Age is Shyam")
else:
	print("The Youngest Age is Ajay")

Output

Enter the Age of Ram :23
Enter the Age of Shyam :21
Enter the Age of Ajay :25
The Youngest Age is Shyam


Example Programs