dictionary in python explained code example
Example 1: dictionary in python
programming_dictionary = {
"Bug": "An error in a program that prevents the program from running as expected.",
"Function": "A piece of code that you can easily call over and over again.",
"Loop": "The action of doing sommething again and again",
}
print(programming_dictionary["Function"])
for key in programming_dictionary:
print(programming_dictionary[key])
programming_dictionary["Variable"] = "The label to store some sort of data"
print(programming_dictionary["Variable"])
programming_dictionary["Variable"] = "Variables are nothing but reserved memory locations to store values. This means that when you create a variableyou reserve some space in memory"
Example 2: dictionary in python
my_dict = {"key": "value", "a": 1, 2: "b"}
print(my_dict["key"])
print(my_dict["a"])
print(my_dict[2])