<?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=Random_Python</id>
	<title>Random Python - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://www.opencircuits.com/index.php?action=history&amp;feed=atom&amp;title=Random_Python"/>
	<link rel="alternate" type="text/html" href="http://www.opencircuits.com/index.php?title=Random_Python&amp;action=history"/>
	<updated>2026-09-12T06:41:49Z</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=Random_Python&amp;diff=78839&amp;oldid=prev</id>
		<title>Russ hensel: 1 revision</title>
		<link rel="alternate" type="text/html" href="http://www.opencircuits.com/index.php?title=Random_Python&amp;diff=78839&amp;oldid=prev"/>
		<updated>2017-01-06T17:28:54Z</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=Random_Python&amp;diff=78838&amp;oldid=prev</id>
		<title>Russ hensel: /* Overview */</title>
		<link rel="alternate" type="text/html" href="http://www.opencircuits.com/index.php?title=Random_Python&amp;diff=78838&amp;oldid=prev"/>
		<updated>2016-10-14T17:25:18Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Overview&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;= Overview =&lt;br /&gt;
&lt;br /&gt;
Sometimes, for example if you wanted to simulate throwing a die, it is useful for the computer to generate random numbers.  There are, as usual, a ton of ways to do this, but here we will keep it simple.  If you want more complexity ( or perhaps more detail than this page ) use the links below.  Please copy the code into your environment and run it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
= A Simple Example =&lt;br /&gt;
All these do the same thing with slight different styles, the first A works but is poor style for sure.&lt;br /&gt;
&lt;br /&gt;
For any of this code to work you have to have this statement first:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import random   # this gives you access to the random &amp;quot;library&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is the first simple, but not good style code.  Should be easy to understand.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
print &amp;quot;randrange 1 to 11 gives numbers including 1 to 10 -- run it 10 times A&amp;quot;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;randrange( 1, 11, ) : &amp;quot;, random.randrange( 1, 11, )   # two items are printed just separate by a comma&lt;br /&gt;
print &amp;quot;randrange( 1, 11, ) : &amp;quot;, random.randrange( 1, 11, )   # the first item printed is a literal&lt;br /&gt;
print &amp;quot;randrange( 1, 11, ) : &amp;quot;, random.randrange( 1, 11, )   # the second item is a call to the random function &lt;br /&gt;
print &amp;quot;randrange( 1, 11, ) : &amp;quot;, random.randrange( 1, 11, )&lt;br /&gt;
print &amp;quot;randrange( 1, 11, ) : &amp;quot;, random.randrange( 1, 11, )&lt;br /&gt;
print &amp;quot;randrange( 1, 11, ) : &amp;quot;, random.randrange( 1, 11, )&lt;br /&gt;
print &amp;quot;randrange( 1, 11, ) : &amp;quot;, random.randrange( 1, 11, )&lt;br /&gt;
print &amp;quot;randrange( 1, 11, ) : &amp;quot;, random.randrange( 1, 11, )&lt;br /&gt;
print &amp;quot;randrange( 1, 11, ) : &amp;quot;, random.randrange( 1, 11, )&lt;br /&gt;
print &amp;quot;randrange( 1, 11, ) : &amp;quot;, random.randrange( 1, 11, )&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When code is repeated it is better style code to put it in a loop ( and perhaps define a function, something we will not do here ).&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
print &amp;quot;randrange 1 to 11 gives numbers including 1 to 10 -- run it 10 times B&amp;quot;&lt;br /&gt;
for ix in range( 0, 10 ):&lt;br /&gt;
     print &amp;quot;randrange( 1, 11, ) : &amp;quot;, random.randrange( 1, 11, )&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This code is slightly different by putting the random value in a variable before printing it.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
print &amp;quot;randrange 1 to 11 gives numbers including 1 to 10 -- run it 10 times C&amp;quot;&lt;br /&gt;
for ix in range( 0, 10 ):&lt;br /&gt;
     random_number  = random.randrange( 1, 11, )&lt;br /&gt;
     print &amp;quot;randrange( 1, 11, ) : &amp;quot;, random_number&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Links =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*'''[https://docs.python.org/2/library/random.html 9.6. random — Generate pseudo-random numbers — Python 2.7.12 documentation ]'''&lt;br /&gt;
*'''[https://stackoverflow.com/questions/3996904/generate-random-integers-between-0-and-9 python - Generate random integers between 0 and 9 - Stack Overflow ]'''&lt;br /&gt;
*'''[https://www.tutorialspoint. com/python/python_lists.htm Python Lists ]'''&lt;br /&gt;
*'''[https://pymotw.com/2/random/ random – Pseudorandom number generators - Python Module of the Week ]'''&lt;br /&gt;
*'''[http://www.pythonforbeginners.com/random/how-to-use-the-random-module-in-python How to use the Random Module in Python ]'''&lt;br /&gt;
*'''[https://www.tutorialspoint. com/python/number_randrange.htm Python Number randrange() Method ]'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Draft]] [[Category:Python]] [[Category:Python Course]]&lt;/div&gt;</summary>
		<author><name>Russ hensel</name></author>
		
	</entry>
</feed>