Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| python [2017/07/28 17:41] – [Iterate over indexes and values of sequence] mgupton | python [2023/03/20 17:33] (current) – [Python] mgupton | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ======Python====== | ======Python====== | ||
| + | * [[https:// | ||
| + | * [[https:// | ||
| + | |||
| + | * [[Python Modules and Packages]] | ||
| + | * [[Python Tools]] | ||
| + | * [[python: | ||
| + | |||
| + | |||
| ======Core Elements & Constructs====== | ======Core Elements & Constructs====== | ||
| =====Lists===== | =====Lists===== | ||
| Line 43: | Line 51: | ||
| </ | </ | ||
| - | =====Iterate over keys and values of dictionary==== | ||
| - | <code python> | ||
| - | for k, v in dict.items(): | ||
| - | print(v) | ||
| - | </ | ||
| - | |||
| - | <code python> | ||
| - | for k in dict.keys(): | ||
| - | print(k + " | ||
| - | </ | ||
| - | <code python> | ||
| - | for v in dict.values(): | ||
| - | print(v + " | ||
| - | </ | ||
| - | |||
| - | =====Iterate over indicies and values of sequence===== | ||
| - | <code python> | ||
| - | a = [" | ||
| - | |||
| - | for k, v in enumerate(a): | ||
| - | |||
| - | print(" | ||
| - | </ | ||
| ======Basic Structures and Constructs====== | ======Basic Structures and Constructs====== | ||
| * If the %%__name__%% variable is set to %%__main__%% the module is being loaded as a main script and program entry point. Otherwise it's being loaded as a library module. | * If the %%__name__%% variable is set to %%__main__%% the module is being loaded as a main script and program entry point. Otherwise it's being loaded as a library module. | ||
| Line 99: | Line 84: | ||
| print(" | print(" | ||
| </ | </ | ||
| + | |||
| + | =====Iterate over keys and values of dictionary==== | ||
| + | <code python> | ||
| + | for k, v in dict.items(): | ||
| + | print(v) | ||
| + | </ | ||
| + | |||
| + | <code python> | ||
| + | for k in dict.keys(): | ||
| + | print(k + " | ||
| + | </ | ||
| + | <code python> | ||
| + | for v in dict.values(): | ||
| + | print(v + " | ||
| + | </ | ||
| + | |||
| + | =====Iterate over indicies and values of sequence===== | ||
| + | <code python> | ||
| + | a = [" | ||
| + | |||
| + | for k, v in enumerate(a): | ||
| + | |||
| + | print(" | ||
| + | </ | ||
| + | |||
| ======Common Elements and Ways====== | ======Common Elements and Ways====== | ||
| ======Determine if variable is defined====== | ======Determine if variable is defined====== | ||
| Line 131: | Line 141: | ||
| </ | </ | ||
| + | =======Resources/ | ||
| + | * [[http:// | ||
| + | * [[https:// | ||