Homework help: Dictionaries on Python

Can someone explain about dictionaries please

have u tried looking into w3schools for this? https://www.w3schools.com/python/python_dictionaries.asp

Hello @girlcode111, in order for others to understand your problem and help you better, I suggest you to add more description to your post, e.g. have you read the official python documentation on dictionary? If so, what is it that you don’t understand/are having troubles with?

1 Like

Dictionary is cpp’s MAP you take couples first is key second is value < key,value> keys must be different , if you want to take value you must know key and take value under its key … watch on youtube tutorial or smth. and do some tasks at ww3 or codeforces .

The main operations on a Python dictionary are storing a value with some key and extracting the value given the key. Dictionaries are optimized to retrieve values when the key is known. Most important features by which you can recognize a Python dictionary are the curly brackets { } and for each item in the dictionary, the separation of the key and value by a colon :. In Python the keys are treated as objects. Any immutable object can be a Python dictionary key. Thus a dictionary could contain mappings for 1 (number), “1” (a string literal consisting of the single digit for “one”) and those are distinct mappings because those keys are different. In awk, Perl, PHP, and Javascript (among others) the key is evaluated into a “scalar” … a type which can be treated as a string or potentially as a number depending on the context in which it’s evaluated. Thus these other languages would only have a single entry in their hashes/associative arrays which would be access via “1” (a string") or 1 (an integer) or 1.0 (a floating point number equivalent to the integer 1).