Skip to content

Commit 124357a

Browse files
committed
Document import random
1 parent 5b26aab commit 124357a

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

docs/VPythonDocs/math.html

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
<p class="Normal">A VPython <a href="VPython_Intro.pdf" target="_blank">tutorial</a></p>
2929
<p class="Normal"><a href="videos.html">Introductory Videos</a></p>
3030
<p class="Normal"><a href="primitives.html">Pictures</a> of 3D objects</p>
31-
<p><select id="menu1" onchange="jumpMenu(this)"></select></p>
32-
<p><select id="menu2" onchange="jumpMenu(this)"></select></p>
33-
<p><select id="menu3" onchange="jumpMenu(this)"></select></p>
31+
<p><select id="menu1" onChange="jumpMenu(this)"></select></p>
32+
<p><select id="menu2" onChange="jumpMenu(this)"></select></p>
33+
<p><select id="menu3" onChange="jumpMenu(this)"></select></p>
3434

3535
<p class="Normal"><a href="new_features.html">What's new</a></p>
3636
<p class="Normal"><a href="http://vpython.org" target="_blank">Classic VPython web site</a><br />
@@ -74,18 +74,22 @@ <h1 class="Heading-1"> <font color="#0000A0">Math Functions</font></h1>
7474
max(a,b,c,..) # maximum of these<br />
7575
min(a,b,c,..) # minimum of these</p>
7676
<p class="Normal">Many of the quantities above are short forms of the JavaScript functions Math.abs(x), Math.sqrt(x), etc. <strong><a href="factorial.html">Here are details</a></strong> of the factorial and combin functions.</p>
77+
<p class="Normal">&nbsp;</p>
78+
<p class="Normal">In general, Python modules cannot be imported into VPython programs, because GlowScript VPython functions in a JavaScript environment. However, one can import the Python &quot;random&quot; module into a VPython program, provided by the RapydScript-NG tool that converts Python to JavaScript. One cannot use the form &quot;from random import *&quot; but must use &quot;import random&quot; or &quot;import random as rr&quot; (or other name) or &quot;from random import randint, uniform&quot; (or other list of functions). Here is <strong><a href="https://docs.python.org/3/library/random.html">documentation</a></strong> of the Python random module. You do not need to import the random module in order to be able to use the random() function described above.</p>
79+
<p class="Normal">&nbsp;</p>
7780
<p class="Normal">There are functions for converting between degrees and
7881
radians, where there are 2*pi radians in 360 degrees: </p>
7982
<p class="program">radians(360) &nbsp;# equal to 2*pi<br />
80-
degrees(2*pi) # equal to 360</p>
83+
degrees(2*pi) # equal to 360 </p>
84+
<p class="Normal">&nbsp;</p>
8185
<p class="Normal">See JavaScript documentation on the <strong><a href="http://www.w3schools.com/jsref/jsref_obj_date.asp" target="_blank">Date</a></strong> object which provides methods for determining the current day etc. </p>
8286
<p class="Normal">Here is a way to determine elapsed time in seconds, with microsecond accuracy, using the clock() function that is also available in the standard Python &quot;time&quot; module. The displayed text is approximately 1.5:</p>
8387
<p class="program">t1 = clock()<br />
8488
sleep(1.5)<br />
8589
t2 = clock()<br />
86-
print(t2-t1)</p>
87-
<p class="Normal"></p>
90+
print(t2-t1) </p>
8891
<p class="Normal">There is also a function msclock() which gives the time in milliseconds instead of seconds.</p>
92+
<p class="Normal">&nbsp;</p>
8993
<p class="Normal">You can <a href="MathJax.html" target="_blank"><strong>use LaTeX</strong></a> to display mathematical expressions on the page.</p>
9094
<br />
9195
<!-- InstanceEndEditable --></td>

0 commit comments

Comments
 (0)