Created
August 26, 2020 04:08
-
-
Save ihzarizkyk/f3c5dd6d818bf4aeceabe9d2fbc9e33b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Author : Mochammad Ihza Rizky Karim | |
''' | |
# Polymorphism | |
# simple example using len function | |
print(len("Polymorphism")) | |
print(len([0,1,2,3])) | |
''' | |
Menggunakan Fungsi len | |
Output : | |
12 (Tipe Data String) | |
4 (Tipe Data List) | |
''' | |
# using class | |
class indonesia: | |
def ibukota(self): | |
print("Jakarta adalah Ibu Kota Negara Indonesia") | |
class malaysia: | |
def ibukota(self): | |
print("Kuala Lumpur adalah Ibu Kota Negara Malaysia") | |
negara1 = indonesia() | |
negara2 = malaysia() | |
for country in (negara1,negara2): | |
country.ibukota() | |
''' | |
Output : | |
Jakarta adalah Ibu Kota Negara Indonesia | |
Kuala Lumpur adalah Ibu Kota Negara Malaysia | |
''' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment