P4B Quiz (12):字典資料型態介紹與使用 by KC 2023-03-23 written by KC 2023-03-23 0 comment Welcome to your quiz -「 P4B Quiz (12):字典資料型態介紹與使用」 Name Email 1. 以下字典 (dictionary) 的鍵 (key) 是什麼? {"a":1,"b":2} 1, 2 "a", "b" "a":1 "b":2 2. 以下執行結果是什麼? Dict={"A":1,"B":"2","C":[3, 3, 3],"D":(5, 5, 5),'E':6,'F':7}Dict["D"] [3, 3, 3] [5, 5, 5] (3, 3, 3) (5, 5, 5) 3. 以下字典 (dictionary) 的值 (value) 是什麼? {"Simple Learn":"2023", "pi day":"0314"} "Simple Learn" "2023" "pi day" 4. 以下執行結果是什麼? my_dict = {0:"Simple", 1:"Learn", 2:"is", 3:"great"}print(my_dict[1]) Simple Learn is great 5. 以下執行結果是什麼? my_dict = {0:"Simple", 1:"Learn", 2:"is", 3:"great"}print(my_dict.get(1)) Simple Learn is great 6. 以下執行結果是什麼? my_dict = {0:"Simple", 1:"Learn", 2:"is", 3:"great"}my_dict[0] = "Python"print(my_dict[1]) Simple Learn is great 7. 以下執行結果是什麼? my_dict = {0:"Simple", 1:"Learn", 2:"is", 3:"great"}my_dict[0] = "Python"print(my_dict.get(4)) Learn great None KeyError 8. 以下執行結果是什麼? my_dict = {0:"Simple", 1:"Learn", 2:"is", 3:"great"}print(my_dict.pop(2)) Learn is 2 1 9. 以下執行結果是什麼? my_dict = {0:"Simple", 1:"Learn", 2:"is", 3:"great"}print(my_dict.popitem()) (0, 'Simple') (1, 'Learn') (2, 'is') (3, 'great') 10. 以下執行結果是什麼? my_dict = {0:"Simple", 1:"Learn", 2:"is", 3:"great"}my_dict.clear()print(my_dict) {0} {1:"Learn", 2:"is", 3:"great"} {} {0:"Simple", 1:"Learn", 2:"is", 3:"great"} Time is Up! Time's up Share 0 FacebookTwitterPinterestEmail previous post P4B Quiz (11):集合資料型態介紹與使用 next post P4B Quiz (13):條件判斷式 – if 相關敘述及使用