Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 - What is a dictionary? a. It is a collection of items that are ordered and unchangeable. b. It is a data type that

1 - What is a dictionary?

a. It is a collection of items that are ordered and unchangeable.

b. It is a data type that holds data or information in a key-value order.

c. It is an instance of the dictionary class.

d. It is a collection of data items that are unordered and unique.

2 - How are ordered dictionaries (OrderedDict) different from a normal dictionary?

a. Both dictionaries are same in nature.

b. OrderedDict does not maintain the order of keys, whereas a normal dictionary does.

c. OrderedDict maintains the insertion order of keys while a normal dictionary does not.

d. Both dictionaries don't maintain any order.

3 - What is the output of the following script?

dictionary_masher ={ "name":"Amos", "age": 100 } print(dictionary_masher)

a. { 'name': 'Amos", 'age': '100' } b. { 'Amos': 'name', '100': age } c. { name: Amos, age: 100 } d. { 'name': 'Amos', 'age': 100 }

4 - In the following code a = {1, 2, 3}, which method should we use to remove last item from the set but not return it?

a. delete() b. clear() c. pop() d. remove()

5 - Which operation would you use on the following two sets to get the expected output?

a = {1,2,3,4,5,6} b = {1,2,3,7,8,9,10} Output: {1,2,3,4,5,6,7,8,9,10}

a. Intersection b. Difference c. Union d. Subsets

6 - What is the output of the following script?

a = {1,2,3,4,5,6} b = {1,2,3,7,8,9,10} a - b

a. {7, 8, 9, 10} b. {4, 5, 6, 7, 8, 9, 10} c. {1, 2, 3} d. {4, 5, 6}

7 - Which operation would you use to add a data "F" to a given set?

myset={"A", "B", "C", "D", "E"};

a. insert() b. update() c. add() d. append()

8 - Which statement is true about the copy() method of dictionaries?

a. The copy() method is used to create shallow copies of dictionaries.

b. The copy() method is used to create a new dictionary and delete the old dictionary.

c. The copy() method is used to create deep copies of dictionaries.

d. The copy() method is used to create multiple copies of dictionaries.

9 - What is the output of the following script?

>>> a= {"name": "Skandar Keynes", "age": "24", "sex": "male"} >>> b = a.setdefault("name") >>> print(b)

a. Skandar Keynes b. 24 c. name d. male

10 - Which of the following statement is true about frozen sets?

a. Frozen set objects are never initialized.

b. Frozen sets are immutable in nature and do not support adding or removing of items.

c. They are useful for holding items that change.

d. frozenset() is a user-defined function.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data And Databases

Authors: Jeff Mapua

1st Edition

1978502257, 978-1978502253

More Books

Students also viewed these Databases questions

Question

How wide are Salary Structure Ranges?

Answered: 1 week ago