Python da If Elif Metodu
Merhaba arkadaşlar bu Python da if metoduna örnek vereceğiz. İlk önce konsol ekranında kullanıcıya Sinema veya Tiyatro seçeneklerinden birisini seçmesini isteyeceğiz. Sonra öğrenci olup olmadığını soracağız. Eğer öğrenciyse bilette indirim uygulanacak. Bu koşulları If Elif metoduyla yapacağız.

Şekil 1
choice = input("Press (1) for Cinema, (2) for Theatre : ")
student = input("Are you student? (Y/N) : ")
pay = 0
# non-discounted ticket
if choice == '1':
pay = 25 #cinema
elif choice == '2':
pay = 20 #theatre
# student ticket discount
if student =='Y' or student =='y':
pay=pay / 2 #50%
print("The amount you need to pay :{}".format('$'+ str(pay)))
Bir makalenin daha sonuna geldik. Bir sonraki makalede görüşmek üzere. Bahadır ŞAHİN