Skip to content

Instantly share code, notes, and snippets.

View abdullahaaf's full-sized avatar

Abdullah Amin Firdaus abdullahaaf

View GitHub Profile
honda_jazz = Kendaraan(4,'jazz',4,4,250)
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
mobil = Kendaraan()
print(mobil) # <__main__.Kendaraan instance at 0x7fb1de6c2638>
class Kendaraan:
pass
dictionary_tk = {
"name": "Leandro",
"nickname": "Tk",
"nationality": "Brazilian",
"age": 24
}
for attribute, value in dictionary_tk.items():
print("My %s is %s" %(attribute, value))
dictionary = { "some_key": "some_value" }
for key, value in dictionary.items():
print("%s --> %s" %(key, value))
# some_key --> some_value
dictionary = { "some_key": "some_value" }
for key in dictionary:
print("%s --> %s" %(key, dictionary[key]))
# some_key --> some_value
bookshelf = [
"The Effective Engineer",
"The 4 hours work week",
"Zero to One",
"Lean Startup",
"Hooked"
]
for book in bookshelf:
dictionary_tk = {
"name": "Leandro",
"nickname": "Tk",
"nationality": "Brazilian"
}
dictionary_tk['age'] = 24
print(dictionary_tk) # {'nationality': 'Brazilian', 'age': 24, 'nickname': 'Tk', 'name': 'Leandro'}
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