This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
en:maps [2020/04/23 15:17] admin created |
en:maps [2020/04/23 15:24] (current) admin |
||
---|---|---|---|
Line 2: | Line 2: | ||
Maps, also known ad dictionaries in Python, are created using the [[Map|Map]] statement. | Maps, also known ad dictionaries in Python, are created using the [[Map|Map]] statement. | ||
- | You may use the [[arraylength|Array length]] [?] oerator | + | You may use the [[arraylength|Array length]] [?] operator |
+ | Internally maps are stores in alphabetic order. You may easily loop through a map using the [[fornext|For Next]] statement. | ||
+ | < | ||
+ | map grades | ||
+ | |||
+ | grades[' | ||
+ | grades[' | ||
+ | grades[' | ||
+ | |||
+ | total = 0 | ||
+ | foreach name in grades | ||
+ | ? name, grades[name] | ||
+ | total = total + grades[name] | ||
+ | next name | ||
+ | |||
+ | ? "the class average is", total/ | ||
+ | </ | ||
+ | displays | ||
+ | < | ||
+ | bob 90 | ||
+ | jimmy 76 | ||
+ | mary 96 | ||
+ | the class average is 87.3333333333 | ||
+ | </ | ||
==== History ==== | ==== History ==== | ||
|2.0.0.0|New to version| | |2.0.0.0|New to version| | ||