python

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
python [2017/07/28 17:37] – [Iterate over keys and values of dictionary] mguptonpython [2023/03/20 17:33] (current) – [Python] mgupton
Line 1: Line 1:
 ======Python====== ======Python======
 +  * [[https://www.python.org/dev/peps/pep-0008/|PEP 8 -- Style Guide for Python Code]]
 +  * [[https://pep8.org/]]
 +
 +  * [[Python Modules and Packages]]
 +  * [[Python Tools]]
 +  * [[python:Handling Dates]]
 +
 +
 ======Core Elements & Constructs====== ======Core Elements & Constructs======
 =====Lists===== =====Lists=====
Line 43: Line 51:
 </code> </code>
  
-=====Iterate over keys and values of dictionary==== 
-<code python> 
-for k, v in dict.items(): 
-    print(v) 
-</code> 
- 
-<code python> 
-for k in dict.keys(): 
-    print(k + "\n") 
-</code> 
-<code python> 
-for v in dict.values(): 
-    print(v + "\n") 
-</code> 
- 
-=====Iterate over indexes and values of sequence===== 
-<code python> 
-a = ["a", "b", "c"] 
- 
-for k, v in enumerate(a): 
- 
-    print("%s, %s\n" % (k,v)) 
-</code> 
 ======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("%s" % c)     print("%s" % c)
 </code> </code>
 +
 +=====Iterate over keys and values of dictionary====
 +<code python>
 +for k, v in dict.items():
 +    print(v)
 +</code>
 +
 +<code python>
 +for k in dict.keys():
 +    print(k + "\n")
 +</code>
 +<code python>
 +for v in dict.values():
 +    print(v + "\n")
 +</code>
 +
 +=====Iterate over indicies and values of sequence=====
 +<code python>
 +a = ["a", "b", "c"]
 +
 +for k, v in enumerate(a):
 +
 +    print("%s, %s\n" % (k,v))
 +</code>
 +
 ======Common Elements and Ways====== ======Common Elements and Ways======
 ======Determine if variable is defined====== ======Determine if variable is defined======
Line 131: Line 141:
 </code> </code>
  
 +=======Resources/References======
 +  * [[http://docs.python-guide.org/en/latest/|The Hitchhiker’s Guide to Python]]
 +  * [[https://realpython.com/|Real Python]], tutorials and other learning resources
  
  • python.1501263427.txt.gz
  • Last modified: 2017/07/28 17:37
  • by mgupton