A general conceptual question about dictionaries


#1

1) Why aren't dictionaries printed in a specific order? Is it because they don't have ordered indexes, but keys that don't specify order?
2) And even then, couldn't there be an inherent order, like an index of some sort linked to each key-value pair? Wouldn't this still make dictionaries callable as functions, because two different inputs linked to the same output is still a function? or are functions defined differently in code than math?
3) Also, because there is no order, what determines the order the dictionary will be printed in?


#2

The location in memory of the value is determined by the key. The key is read and an algorithm is applied that outputs the location for where to look up/store the value.

Look up hash table for details


#3

thnx :slightly_smiling:


#4

yes, i looked it up, the algorithm is very complicated, and has imports, functions, and commands i don't know about. But i get the general idea. this analagous they used really made me understand. its based on types of the keys and values, and a whole bunch of other things i don't understand: ""The legal system is made up of civil courts, criminal courts and specialty courts such as family law courts and bankruptcy court. Each court has its own jurisdiction, which refers to the cases that the court is allowed to hear. In some instances, a case can only be heard in one type of court. For example, a bankruptcy case must be heard in a bankruptcy court. In other instances, there may be several potential courts with jurisdiction. For example, a federal criminal court and a state criminal court would each have jurisdiction over a crime that is a federal drug offense but that is also an offense on the state level.",
"The legal system is comprised of criminal and civil courts and specialty courts like bankruptcy and family law courts. Every one of the courts is vested with its own jurisdiction. Jurisdiction means the types of cases each court is permitted to rule on. Sometimes, only one type of court can hear a particular case. For instance, bankruptcy cases an be ruled on only in bankruptcy court. In other situations, it is possible for more than one court to have jurisdiction. For instance, both a state and federal criminal court could have authority over a criminal case that is illegal under federal and state drug laws.",
"In many jurisdictions the judicial branch has the power to change laws through the process of judicial review. Courts with judicial review power may annul the laws and rules of the state when it finds them incompatible with a higher norm, such as primary legislation, the provisions of the constitution or international law. Judges constitute a critical force for interpretation and implementation of a constitution, thus de facto in common law countries creating the body of constitutional law."]
I have never really had experience to prove to me that coding is a science. But now... yes, it is a very huge branch of science, in its own right


#5

What isn't computer science?

DNA is code, apply the rules of the world we live in and we will have computed you.
(And the fact that we exist should be proof enough that this is something that we are able to do.)


#6

lol, so true, so true