Choose the correct output for
>>>dict(m=8, n =9)

(a) {m=8,n=9}

(b) {‘m’ = 8. ‘n’ =9}

(c) {‘m’: 8, ‘n’ :9}

(d) {m:n, 8:9}

 

Answer:

The code uses the dict() function to create a dictionary object in Python. 

The dict() function takes keyword arguments, where each argument is a key followed by an equal sign and a value . For example, dict(m=8, n=9) means that the key ‘m’ has the value 8 and the key ‘n’ has the value 9. 

The syntax for representing a dictionary object in Python is to use curly braces {} and separate each key-value pair by a comma. The key and the value are separated by a colon :. For example, {‘m’: 8, ‘n’: 9} is a valid dictionary object in Python.

Therefore, the only option that matches this syntax is (c) {‘m’: 8, ‘n’ :9}.

So, the correct answer is (c) {‘m’: 8, ‘n’ :9}.

 

Go Ad-free
Davneet Singh's photo - Co-founder, Teachoo

Made by

Davneet Singh

Davneet Singh has done his B.Tech from Indian Institute of Technology, Kanpur. He has been teaching from the past 14 years. He provides courses for Maths, Science and Computer Science at Teachoo