<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://www.opencircuits.com/index.php?action=history&amp;feed=atom&amp;title=Python_Example_Code</id>
	<title>Python Example Code - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://www.opencircuits.com/index.php?action=history&amp;feed=atom&amp;title=Python_Example_Code"/>
	<link rel="alternate" type="text/html" href="http://www.opencircuits.com/index.php?title=Python_Example_Code&amp;action=history"/>
	<updated>2026-08-29T18:18:57Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.34.2</generator>
	<entry>
		<id>http://www.opencircuits.com/index.php?title=Python_Example_Code&amp;diff=82620&amp;oldid=prev</id>
		<title>Russ hensel: /* A Trick for Example Code */</title>
		<link rel="alternate" type="text/html" href="http://www.opencircuits.com/index.php?title=Python_Example_Code&amp;diff=82620&amp;oldid=prev"/>
		<updated>2020-05-25T20:43:38Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;A Trick for Example Code&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 20:43, 25 May 2020&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot; &gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;If you develop much in Python you may find it useful to save example code, snippets of code, or templates to copy and use later.  If you do this it is also nice to be able to run the code so you can check it out and mess with it a bit.  Keep in mind that copying code is easier than writing it.  Be an expert at both  &lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;If you develop much in Python you may find it useful to save example code, snippets of code, or templates to copy and use later.  If you do this it is also nice to be able to run the code so you can check it out and mess with it a bit.  Keep in mind that copying code is easier than writing it.  Be an expert at both  &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;= A Trick for Example Code =&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;= A Trick for &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Keeping Your Own &lt;/ins&gt;Example Code =&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This page presents a trick that makes this process more convenient.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This page presents a trick that makes this process more convenient.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l49&quot; &gt;Line 49:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 49:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;= Links to Example Code =&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;= Links to Example Code =&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Russ hensel</name></author>
		
	</entry>
	<entry>
		<id>http://www.opencircuits.com/index.php?title=Python_Example_Code&amp;diff=78791&amp;oldid=prev</id>
		<title>Russ hensel: 1 revision</title>
		<link rel="alternate" type="text/html" href="http://www.opencircuits.com/index.php?title=Python_Example_Code&amp;diff=78791&amp;oldid=prev"/>
		<updated>2017-01-06T17:28:53Z</updated>

		<summary type="html">&lt;p&gt;1 revision&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 17:28, 6 January 2017&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Russ hensel</name></author>
		
	</entry>
	<entry>
		<id>http://www.opencircuits.com/index.php?title=Python_Example_Code&amp;diff=78790&amp;oldid=prev</id>
		<title>Russ hensel: /* Links to Example Code */</title>
		<link rel="alternate" type="text/html" href="http://www.opencircuits.com/index.php?title=Python_Example_Code&amp;diff=78790&amp;oldid=prev"/>
		<updated>2016-10-10T13:48:44Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Links to Example Code&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;If you develop much in Python you may find it useful to save example code, snippets of code, or templates to copy and use later.  If you do this it is also nice to be able to run the code so you can check it out and mess with it a bit.  Keep in mind that copying code is easier than writing it.  Be an expert at both &lt;br /&gt;
&lt;br /&gt;
= A Trick for Example Code =&lt;br /&gt;
&lt;br /&gt;
This page presents a trick that makes this process more convenient.&lt;br /&gt;
&lt;br /&gt;
In the past I kept the code in moderate sized files with many examples in each.  I would comment out all the examples I wanted to keep but not run, then run the one I did.  The commenting process was more of a pain than I wanted.  In my simple trick I define the code in a function then only have to comment in and out the function call.  I will list an example here you can use it as a template to make more of your own.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# ----------------------------------------&lt;br /&gt;
def   ex_0():&lt;br /&gt;
    print &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    ================ ex_0(): Powers ===============&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    a     = 10&lt;br /&gt;
    b     = 20&lt;br /&gt;
    c     = a**b       # powers = 10 to the power 20&lt;br /&gt;
    print c&lt;br /&gt;
&lt;br /&gt;
ex_0()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# ----------------------------------------&lt;br /&gt;
def   ex_1():&lt;br /&gt;
    print &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    ================ ex_1 Floor Division rounded away from zero ===============&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    print( &amp;quot;10/4 = &amp;quot;     + str( 10/4 ) )&lt;br /&gt;
    print( &amp;quot;10//4 = &amp;quot;    + str( 10//4 ) )&lt;br /&gt;
    print( &amp;quot;10.//4. = &amp;quot;    + str( 10.//4. ) )&lt;br /&gt;
    print( &amp;quot;-10.//4. = &amp;quot;    + str( -10.//4. ) )&lt;br /&gt;
&lt;br /&gt;
#ex_1()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# ==========================================================&lt;br /&gt;
def   ex_2():&lt;br /&gt;
    print &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    ================ ex_2(): modulo or remainder ===============&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    a = [30,40,50,60,70,80,90,100,120]&lt;br /&gt;
    a     = range( 0, 40 )&lt;br /&gt;
    for ix, i_a in enumerate(a):&lt;br /&gt;
       if ix%3 == 0:&lt;br /&gt;
          print ix, i_a&lt;br /&gt;
#ex_2()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Links to Example Code =&lt;br /&gt;
There is also a lot of example code out on the web.  It can be useful if it does not take too long to find.  You can try these.&lt;br /&gt;
&lt;br /&gt;
*'''[https://wiki.python.org/moin/SimplePrograms SimplePrograms - Python Wiki ]'''&lt;br /&gt;
*'''[http://sandbox.mc.edu/~bennet/python/code/ Code Examples ]'''&lt;br /&gt;
*'''[http://www.java2s.com/Code/Python/CatalogPython.htm Python examples (example source code) Organized by topic ]'''&lt;br /&gt;
*'''[https://wiki.python.org/moin/CheeseShopTutorial CheeseShopTutorial - Python Wiki ]'''&lt;br /&gt;
*'''[http://www.pythonforbeginners.com/ Pythonforbeginners.com - Learn Python by Example ]'''&lt;br /&gt;
*'''[http://www.pythonforbeginners.com/code-snippets-source-code/python-code-examples Python Code Examples ]'''&lt;br /&gt;
*'''[http://www.pythonforbeginners.com/code-snippets-source-code/python-code-snippets-2 Python Code Snippets ]'''&lt;br /&gt;
*'''[https://wiki.python.org/moin/BeginnerErrorsWithPythonProgramming BeginnerErrorsWithPythonProgramming - Python Wiki ]'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-----------&lt;br /&gt;
&lt;br /&gt;
*'''[[Category:Courses]]''' &lt;br /&gt;
*'''[[User:Russ_hensel]]'''&lt;br /&gt;
&lt;br /&gt;
*'''[[]]'''&lt;br /&gt;
&lt;br /&gt;
-------------&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[category:Python]]  [[category:Python Course]]&lt;/div&gt;</summary>
		<author><name>Russ hensel</name></author>
		
	</entry>
</feed>