My Team (LOOP Community)

My Team (LOOP Community)

Sabtu, 25 April 2015

CODING PYTHON - Menghitung SKOR





Coding Python - Menghitung SKOR

class sepak_bola(object):
    tim         = str
    main_ke_1   = str
    main_ke_2   = str
    ket         = str
    medal       = str

    def _init_(self,tim,main_ke_1,main_ke_2,ket,medal):
        self.tim        = tim1
        self.main_ke_1  = main_ke_1
        self.main_ke_2  = main_ke_2
        self.ket        = ket
        self.medal      = medal

    def get_ket(self):
        if self.main_ke_1 == "M" and self.main_ke_2 == "M":
            ket ="Skor 2"
        elif self.main_ke_1 =="M" or "K" and self.main_ke_2 =="K" or "M":
            ket ="Skor 1"
        else:
            ket ="Skor 0"
        return ket
    def get_medal(self):
        if self.main_ke_1=="M" and self.main_ke_2 =="M":
            medal = "Medali Emas"
        elif self.main_ke_1=="M" and self.main_ke_2=="K":
            medal = "Medali Perak"
        elif self.main_ke_1=="K" and self.main_ke_2=="M":
            medal = "Medali Perunggu"
        else:
            medal = "Latihan lagi ya :)"
        return medal

def main():
    a = sepak_bola()

    a.tim = raw_input("Masukan Nama tim : ")
    a.main_ke_1 = raw_input("Masukan main ke 1 :")
    a.main_ke_2 = raw_input("masukan main ke 2 :")

    print "Program Menghitung Skor"
    print "Author By : Frika Da Cintia"
    print "Teknik Informatika LPKIA"
    print "============================="
    print " Nama Tim    : ",a.tim
    print " Main Ke-1   : ",a.main_ke_1
    print " Main Ke-2   : ",a.main_ke_2
    print " Skor        : ",a.get_ket()
    print " Keterangan  : ",a.get_medal()

if __name__ == '__main__':
    main()

Tidak ada komentar:

Posting Komentar