This file contains hidden or 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
honda_jazz = Kendaraan(4,'jazz',4,4,250) |
This file contains hidden or 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
class Kendaraan: | |
def __init__(self, jumlah_roda, brand, jumlah_kursi, jumlah_pintu, maksimum_kecepatan): | |
self.jumlah_roda = jumlah_roda | |
self.brand = brand | |
self.jumlah_kursi = jumlah_kursi | |
self.jumlah_pintu = jumlah_pintu | |
self.maksimum_kecepatan = maksimum_kecepatan |
This file contains hidden or 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
mobil = Kendaraan() | |
print(mobil) # <__main__.Kendaraan instance at 0x7fb1de6c2638> |
This file contains hidden or 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
class Kendaraan: | |
pass |
This file contains hidden or 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
dictionary_tk = { | |
"name": "Leandro", | |
"nickname": "Tk", | |
"nationality": "Brazilian", | |
"age": 24 | |
} | |
for attribute, value in dictionary_tk.items(): | |
print("My %s is %s" %(attribute, value)) | |
This file contains hidden or 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
dictionary = { "some_key": "some_value" } | |
for key, value in dictionary.items(): | |
print("%s --> %s" %(key, value)) | |
# some_key --> some_value |
This file contains hidden or 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
dictionary = { "some_key": "some_value" } | |
for key in dictionary: | |
print("%s --> %s" %(key, dictionary[key])) | |
# some_key --> some_value |
This file contains hidden or 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
bookshelf = [ | |
"The Effective Engineer", | |
"The 4 hours work week", | |
"Zero to One", | |
"Lean Startup", | |
"Hooked" | |
] | |
for book in bookshelf: |
This file contains hidden or 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
dictionary_tk = { | |
"name": "Leandro", | |
"nickname": "Tk", | |
"nationality": "Brazilian" | |
} | |
dictionary_tk['age'] = 24 | |
print(dictionary_tk) # {'nationality': 'Brazilian', 'age': 24, 'nickname': 'Tk', 'name': 'Leandro'} |
This file contains hidden or 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
dictionary_tk = { | |
"name": "Leandro", | |
"nickname": "Tk", | |
"nationality": "Brazilian", | |
"age": 24 | |
} | |
print("My name is %s" %(dictionary_tk["name"])) # My name is Leandro | |
print("But you can call me %s" %(dictionary_tk["nickname"])) # But you can call me Tk | |
print("And by the way I'm %i and %s" %(dictionary_tk["age"], dictionary_tk["nationality"])) # And by the way I'm Brazilian |