Course Content
ฟังก์ชัน
การสร้างและเรียกใช้ฟังก์ชัน, พารามิเตอร์และอาร์กิวเมนต์, ค่าที่ส่งกลับจากฟังก์ชัน
0/5
Private: SIT325 การเขียนโปรแกรมคอมพิวเตอร์-Digital Skill Course Certification for Government Personnel

ตัวอย่างการใช้เมธอด:

Python
person = {'name': 'John', 'age': 30, 'city': 'New York'}

print(person.keys())   # dict_keys(['name', 'age', 'city'])
print(person.values()) # dict_values(['John', 30, 'New York'])
print(person.items())  # dict_items([('name', 'John'), ('age', 30), ('city', 'New York')])

print(person.get('age'))     # 30
print(person.get('phone'))   # None
print(person.get('phone', 'N/A')) # N/A

person.update({'phone': '123-456-7890'})
print(person) # {'name': 'John', 'age': 30, 'city': 'New York', 'phone': '123-456-7890'}