Q1. Write a program to get largest of two number in python?
# largest of 2 numbers
num1 = int(input("Enter 1st number: "))
num2 = int(input("Enter 2nd number: "))
if(num1 > num2):
print(num1, " is the largest of number ",num2)
else:
print(num2," is the largest of number ", num1)
Q2. Write program to get largest of three numbers in python?
# largest of 3 numbers
num1 = int(input("Enter 1st number: "))
num2 = int(input("Enter 2nd number: "))
num3 = int(input("Enter 3rd number: "))
if(num1 > num2 and num1 > num3):
print(num1, " is the largest of number ",num2, "and", num3)
elif(num2 > num1 and num2 > num3):
print(num2, " is the largest of number ",num1, "and", num3)
else:
print(num3, " is the largest of number ",num1, "and", num2)
Comments
Post a Comment