If I understand your problem correctly all you need to do is use the name of the function to call it ie:<br>
<br>
def func():<br>
&nbsp;&nbsp;&nbsp; print &quot;hello world&quot;<br>
<br>
func()<br>
<br>
would give the output<br>
<br>
&quot;hello world&quot;<br><br><div><span class="gmail_quote">On 7/10/05, <b class="gmail_sendername">Nathan Pinno</b> &lt;<a href="mailto:falcon3166@hotmail.com">falcon3166@hotmail.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
&nbsp;&nbsp;Hi all,<br><br>&nbsp;&nbsp;How do I make Python get a def? Is it the &quot;get&quot; function, or something<br><br>else? I need to know so that I can get a def for that computer<br>MasterMind(tm) game that I'm writing.<br><br>&nbsp;&nbsp;BTW, I took your advice, and wrote some definitions for my Giant
<br>Calculator program. Might make the code easier to read, but harder to<br>code<br>because I have to keep going to the top to read the menu. Not that fun,<br>but<br>necessary for a smooth program, I guess.<br><br>&nbsp;&nbsp;Nathan Pinno
<br><br>&nbsp;&nbsp;&quot;Steven D'Aprano&quot; &lt;<a href="mailto:steve@REMOVETHIScyber.com.au">steve@REMOVETHIScyber.com.au</a>&gt; wrote in message<br>news:pan.2005.07.03.02.30.28.82992@REMOVETHIScyber.com.au...<br>&nbsp;&nbsp;&gt; On Sat, 02 Jul 2005 00:25:00 -0600, Nathan Pinno wrote:
<br>&nbsp;&nbsp;&gt;&gt;&nbsp;&nbsp; Hi all.<br>&nbsp;&nbsp;&gt;&gt;&nbsp;&nbsp; How do I make the computer generate 4 random numbers for the<br>guess? I<br>want<br>&nbsp;&nbsp;&gt;&gt; to know because I'm writing a computer program in Python like the<br>game<br>&nbsp;&nbsp;&gt;&gt; MasterMind.
<br>&nbsp;&nbsp;&gt; First you get the computer to generate one random number. Then you<br>do it<br>&nbsp;&nbsp;&gt; again three more times.<br>&nbsp;&nbsp;&gt; If you only need to do it once, you could do it this way:<br>&nbsp;&nbsp;&gt; import random&nbsp;&nbsp;# you need this at the top of your program
<br>&nbsp;&nbsp;&gt; x0 = random.random()<br>&nbsp;&nbsp;&gt; x1 = random.random()<br>&nbsp;&nbsp;&gt; x2 = random.random()<br>&nbsp;&nbsp;&gt; x3 = random.random()<br>&nbsp;&nbsp;&gt; But if you need to do it more than once, best to create a function<br>that<br>&nbsp;&nbsp;&gt; returns four random numbers in one go.
<br>&nbsp;&nbsp;&gt; def four_random():<br>&nbsp;&nbsp;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&quot;&quot;&quot;Returns a list of four random numbers.&quot;&quot;&quot;<br>&nbsp;&nbsp;&gt;&nbsp;&nbsp;&nbsp;&nbsp;L = []&nbsp;&nbsp;# start with an empty list<br>&nbsp;&nbsp;&gt;&nbsp;&nbsp;&nbsp;&nbsp;for i in range(4):<br>&nbsp;&nbsp;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;L.append
(random.random())<br>&nbsp;&nbsp;&gt;&nbsp;&nbsp;&nbsp;&nbsp;return L<br>&nbsp;&nbsp;&gt; and use it this way:<br>&nbsp;&nbsp;&gt; rand_nums = four_random()<br>&nbsp;&nbsp;&gt; # rand_nums is a list of four numbers<br>&nbsp;&nbsp;&gt; print rand_nums[0]&nbsp;&nbsp;# prints the first random number<br>
&nbsp;&nbsp;&gt; print rand_nums[3]&nbsp;&nbsp;# prints the last one<br>&nbsp;&nbsp;&gt; or like this:<br>&nbsp;&nbsp;&gt; alpha, beta, gamma, delta = four_random()<br>&nbsp;&nbsp;&gt; # four names for four separate numbers<br>&nbsp;&nbsp;&gt; Steven.<br>&nbsp;&nbsp;&gt; <a href="http://mail.python.org/mailman/listinfo/python-list">
http://mail.python.org/mailman/listinfo/python-list</a><br><br><br>_______________________________________________<br>Tutor maillist&nbsp;&nbsp;-&nbsp;&nbsp;<a href="mailto:Tutor@python.org">Tutor@python.org</a><br><a href="http://mail.python.org/mailman/listinfo/tutor">
http://mail.python.org/mailman/listinfo/tutor</a><br></blockquote></div><br>