[Tutor] 'elp!!!!!!!1Totally Clueless Newbie In Distress

Karl Wittgenstein miago.python at gmail.com
Sat Jan 20 14:23:55 CET 2007


I would also like to ask what skills you think I should develop so I can
approach programming more
' natively', and would like to clarify the following issue:
input("Something") usually displays Something when prompting for input;why
is that the case when I run a single line of code and isn't when I use
many?When I run three lines straight in this format,only the first message
and prompt are displayed...That is surely out of the scope of my current
knowledge....Which is not very encompassing,anyway.


2007/1/20, Karl Wittgenstein <miago.python at gmail.com>:
>
> 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!!
>
> "Out of curiosity, what materials are you using to learn how to program?"
>
> 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.Ialso 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...
> 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!
>
>
> 2007/1/19, Danny Yoo <dyoo at hkn.eecs.berkeley.edu>:
> >
> >
> > > I've been dabbling into Python for about 6 weeks now.I'm a Social
> > > Sciences student who just got interested in programming and chose
> > Python
> > > as first language.
> >
> > Out of curiosity, what materials are you using to learn how to program?
> >
> >
> >
> > > Isn't it legal to start a new block of code when starting a
> > > definition?And how come it returns 'variable' not defined,when they
> > are
> > > defined by the = ??Should i make them global?
> >
> > Wait, wait.  I think you may be misunderstanding the use of 'global'.
> > You should not be using global unless you really need it.
> >
> >
> >
> > I see three variables here that you are interested in:
> >
> >     altura_aeronave
> >     largura_aeronave
> >     comprimento
> >
> > Are these always collected together?  If they are related, you should
> > have
> > a single structure that holds them together, rather than represent them
> > as
> > three separate variables.
> >
> >
> > Concretely, you can represent these three values as a single tuple.  You
> > can think of it as a "vector" from your mathematics class.  For example:
> >
> > #################################################
> > def make_measure(start, stop):
> >     """make_measure: number number -> measure
> >     Creates a new measure from start and stop."""
> >     return (start, stop)
> >
> > def measure_start(a_measure):
> >     """measure_start: measure -> number
> >     Selects the start portion of a measure."""
> >     return a_measure[0]
> >
> > def measure_stop(a_measure):
> >     """measure_end: measure -> end
> >     Selects the stop portion of a measure."""
> >     return a_measure[1]
> > #################################################
> >
> >
> > That is, these functions take inputs and produce outputs.  That should
> > be
> > a concept that you are familiar with from your previous experience:
> >
> >     f(x) = 2x     (math notation)
> >
> > is a function that takes a number and produces the double of that
> > number.
> > We write this in Python as:
> >
> > ################
> > def double(x):
> >     """double: number -> number
> >     Returns the double of x."""
> >     return x * 2
> > ################
> >
> >
> > Getting back to the measure example: once we have these functions to
> > build
> > measures and take them apart, we can then use these like this:
> >
> > ################################################
> > ## Small test program
> > m1 = make_measure(3, 4)
> > m2 = make_measure(17, 42)
> > print "m1", measure_start(m1), measure_stop(m1)
> > print "m2", measure_start(m2), measure_stop(m2)
> > ################################################
> >
> > If we dislike the duplication of those last two statements here, we can
> > create a function that doesn't produce an output, but it still takes
> > input:
> >
> >
> > ########################################################################
> > def print_measure(header_name, a_measure):
> >     """print_measure: measure string -> None
> >     Prints out the measurement.
> >     """
> >     print header_name, measure_start(a_measure), measure_stop(a_measure)
> > ########################################################################
> >
> >
> > After we define this helper function "print_measure()", our little
> > program
> > can now look like this:
> >
> > #########################
> > ## Small test program
> > m1 = make_measure(3, 4)
> > m2 = make_measure(17, 42)
> > print_measure("m1", m1)
> > print_measure("m2", m2)
> > #########################
> >
> > Notice that, here, we do not need to say anything about "globals" to
> > make
> > effective programs.  We are simply passing values back and forth as
> > parameters.
> >
> >
> > Does this make sense so far?  If you have any questions, please feel
> > free
> > to ask.  Please continue to reply to Tutor by using your email client's
> > Reply to All feature.
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070120/70f52f3d/attachment.htm 


More information about the Tutor mailing list