<div>First of all let me thank you and Geoframer for your patience;it was very kind that you bothered answering this,as I realize this is very basic stuff.You people are Smart and Caring Dudes,which is a powerful combo for educators!!
</div>
<div> </div>
<div>"Out of curiosity, what materials are you using to learn how to program?"</div>
<div> </div>
<div>Well, mostly Google! I have just finished that RUR-PLE tutorial by Andre Roberge, read some of the Python documentation-not as focused as I should,I admit;many programming concepts are simply totally alien to me,so I also use Wikipedia a
lot.They have a Python tutorial.Sometimes I do some math research, as I only know very basic math,predicate logic and statistics.I also tried a pygame tutorial,but can't import the damn module without at least one error and can't get the damn
chimp.bmp file loaded!!!I used os.path.join("folder","file") to no success...</div>
<div>Thank you again,and once more in advance - if you would be so kind as to point me learning material...My spare time is very short,between graduation and work,so I would appreciate very didatic material...Thank you guys again!
<br><br> </div>
<div><span class="gmail_quote">2007/1/19, Danny Yoo <<a href="mailto:dyoo@hkn.eecs.berkeley.edu">dyoo@hkn.eecs.berkeley.edu</a>>:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><br>> I've been dabbling into Python for about 6 weeks now.I'm a Social<br>> Sciences student who just got interested in programming and chose Python
<br>> as first language.<br><br>Out of curiosity, what materials are you using to learn how to program?<br><br><br><br>> Isn't it legal to start a new block of code when starting a<br>> definition?And how come it returns 'variable' not defined,when they are
<br>> defined by the = ??Should i make them global?<br><br>Wait, wait. I think you may be misunderstanding the use of 'global'.<br>You should not be using global unless you really need it.<br><br><br><br>I see three variables here that you are interested in:
<br><br> altura_aeronave<br> largura_aeronave<br> comprimento<br><br>Are these always collected together? If they are related, you should have<br>a single structure that holds them together, rather than represent them as
<br>three separate variables.<br><br><br>Concretely, you can represent these three values as a single tuple. You<br>can think of it as a "vector" from your mathematics class. For example:<br><br>#################################################
<br>def make_measure(start, stop):<br> """make_measure: number number -> measure<br> Creates a new measure from start and stop."""<br> return (start, stop)<br><br>def measure_start(a_measure):
<br> """measure_start: measure -> number<br> Selects the start portion of a measure."""<br> return a_measure[0]<br><br>def measure_stop(a_measure):<br> """measure_end: measure -> end
<br> Selects the stop portion of a measure."""<br> return a_measure[1]<br>#################################################<br><br><br>That is, these functions take inputs and produce outputs. That should be
<br>a concept that you are familiar with from your previous experience:<br><br> f(x) = 2x (math notation)<br><br>is a function that takes a number and produces the double of that number.<br>We write this in Python as:
<br><br>################<br>def double(x):<br> """double: number -> number<br> Returns the double of x."""<br> return x * 2<br>################<br><br><br>Getting back to the measure example: once we have these functions to build
<br>measures and take them apart, we can then use these like this:<br><br>################################################<br>## Small test program<br>m1 = make_measure(3, 4)<br>m2 = make_measure(17, 42)<br>print "m1", measure_start(m1), measure_stop(m1)
<br>print "m2", measure_start(m2), measure_stop(m2)<br>################################################<br><br>If we dislike the duplication of those last two statements here, we can<br>create a function that doesn't produce an output, but it still takes
<br>input:<br><br><br>########################################################################<br>def print_measure(header_name, a_measure):<br> """print_measure: measure string -> None<br> Prints out the measurement.
<br> """<br> print header_name, measure_start(a_measure), measure_stop(a_measure)<br>########################################################################<br><br><br>After we define this helper function "print_measure()", our little program
<br>can now look like this:<br><br>#########################<br>## Small test program<br>m1 = make_measure(3, 4)<br>m2 = make_measure(17, 42)<br>print_measure("m1", m1)<br>print_measure("m2", m2)<br>#########################
<br><br>Notice that, here, we do not need to say anything about "globals" to make<br>effective programs. We are simply passing values back and forth as<br>parameters.<br><br><br>Does this make sense so far? If you have any questions, please feel free
<br>to ask. Please continue to reply to Tutor by using your email client's<br>Reply to All feature.<br></blockquote></div><br>