B.Sc Computer Science with Data Analytics
Python Programming - Lab
Core Lab 5
Bharathiar University
Program 2 - Write a python program to find the largest three integers using if-else and conditional operator.
Source Code
# Taking user input for three integers
a = int(input("Enter first integer: "))
b = int(input("Enter second integer: "))
c = int(input("Enter third integer: "))
# Find the largest among the three integers using if-else and conditional operators
largest = a if a > b and a > c else (b if b > c else c)
# Displaying the largest number
print("The largest number among", a, ",", b, "and", c, "is:", largest)
OUTPUT:
Enter first integer: 50
Enter second integer: 76
Enter third integer: 23
The largest number among 50 , 76 and 23 is: 76
No comments:
Post a Comment