1) What is a dictionary in Python? a) A collection of ordered pairs of keys and values b) A type of list c) A collection of functions d) A list of strings 2) How do you define a dictionary in Python? a) d = {} b) d = [] c) d = () d) d = dict() 3) What function is used to add a key-value pair to a dictionary in Python? a) A) append() b) B) insert() c) C) update() d) D) add() 4) Which of the following is a correct way to access the value of a specific key in a Python dictionary? a) A) dict[<key>] b) B) dict.get(<key>) c) C) dict.<key>() d) D) Both A and B 5) Which method is used to get a list of all the values in a Python dictionary? a) A) values() b) B) keys() c) C) items() d) D) lists() 6) What method would you use to retrieve a value for a specific key from a Python dictionary? a) A) get() b) B) find() c) C) extract() d) D) fetch() 7) What will the following code output? a) A) None b) B) 0 c) C) "Not Found" d) D) KeyError 8) Which method would you use to remove a key-value pair from a dictionary in Python? a) A) del b) B) remove() c) C) pop() d) D) Both A and C 9) How can you check if a key exists in a Python dictionary? a) A) key in dictionary b) B) dictionary.has_key(key) c) C) key.exists() d) D) dictionary.check_key(key) 10) What does the keys() method return when called on a dictionary? a) A) A list of values b) B) A list of keys c) C) A dictionary d) D) A tuple of key-value pairs
0%
DICTIONARY
共用
共用
共用
由
Stuti023229
Class 11
python
編輯內容
列印
嵌入
更多
作業
排行榜
顯示更多
顯示更少
此排行榜當前是私有的。單擊
共用
使其公開。
資源擁有者已禁用此排行榜。
此排行榜被禁用,因為您的選項與資源擁有者不同。
還原選項
問答遊戲
是一個開放式範本。它不會為排行榜生成分數。
需要登錄
視覺風格
字體
需要訂閱
選項
切換範本
顯示所有
播放活動時將顯示更多格式。
打開結果
複製連結
QR 代碼
刪除
恢復自動保存:
?