in Technology by

How will you create a dictionary in python?

1 Answer

0 votes
by

Dictionaries are enclosed by curly braces ({ }) and values can be assigned and accessed using square braces ([]).

dict = {}

dict['one'] = "This is one"

dict[2]     = "This is two"

tinydict = {'name': 'john','code':6734, 'dept': 'sales'}

Related questions

0 votes
    How will you create a dictionary using tuples in python?...
asked Nov 24, 2020 in Technology by JackTerrance
0 votes
    I have a file that looks like this: NODE=SC-1,CPU=90 NODE=SC-1,MEM=10 NODE=SC-1,FS=80 ... questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    I have a file that looks like this: NODE=SC-1,CPU=90 NODE=SC-1,MEM=10 NODE=SC-1,FS=80 ... questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    Can the Python list comprehension syntax be used to create dictionaries? For an example: By iterating over pairs of ... #doesn't work Select the correct answer from above options...
asked Jan 22, 2022 in Education by JackTerrance
0 votes
    How will you get all the values from the dictionary?...
asked Nov 24, 2020 in Technology by JackTerrance
0 votes
    How will you get all the keys from the dictionary?...
asked Nov 24, 2020 in Technology by JackTerrance
0 votes
    In Python 2.7, I could get dictionary keys, values, or items as a list: >>> newdict = {1:0, 2:0, 3:0} ... to return a list in Python 3? Select the correct answer from above options...
asked Feb 4, 2022 in Education by JackTerrance
0 votes
    In python3 console, input those: >>> import sys >>> sys.version_info sys.version_info(major=3, minor= ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 14, 2022 in Education by JackTerrance
0 votes
    In python3 console, input those: >>> import sys >>> sys.version_info sys.version_info(major=3, minor= ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 8, 2022 in Education by JackTerrance
0 votes
    In python3 console, input those: >>> import sys >>> sys.version_info sys.version_info(major=3, minor= ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 8, 2022 in Education by JackTerrance
0 votes
    I have a dictionary d full of a collection of dataframes: key type size value gm1 dataframe mxn .. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    Describe the process to create a table in the data dictionary?...
asked Jan 4, 2021 in Technology by JackTerrance
0 votes
    So the idea is that users can create collections with many pairs of words in it. For example, they ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 14, 2022 in Education by JackTerrance
0 votes
    Is it possible to retrieve items from a Python dictionary in the order that they were inserted? JavaScript ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 24, 2022 in Education by JackTerrance
0 votes
    For the given points, how will you calculate the Euclidean distance in Python?...
asked Apr 26, 2021 in Technology by JackTerrance
...