Program Python untuk Menemukan Terbesar Di Antara Tiga Angka


Dalam program di bawah ini, tiga angka disimpan di num1, num2 dan num3 masing-masing. Kami telah menggunakan if...elif...else tangga untuk menemukan yang terbesar di antara ketiganya dan menampilkannya.

Kode sumber

# Python program to find the largest number among the three input numbers

# change the values of num1, num2 and num3
# for a different result
num1 = 10
num2 = 14
num3 = 12

# uncomment following lines to take three numbers from user
#num1 = float(input("Enter first number: "))
#num2 = float(input("Enter second number: "))
#num3 = float(input("Enter third number: "))

if (num1 >= num2) and (num1 >= num3):
   largest = num1
elif (num2 >= num1) and (num2 >= num3):
   largest = num2
   largest = num3

print("The largest number is", largest)


The largest number is 14.0

catatan: Untuk menguji program, ubah nilai num1, num2 dan num3.

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

Leave a Reply

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