1.6, tutorial, and floating point (was Re: varibles)

Brendhan Horne brendhan at bellsouth.net
Thu Sep 21 21:21:00 EDT 2000


Thank for the responses I went to
http://pythonlabs.com/pub/www.python.org/doc/1.6/tut/tut.html
that is where I got my tutorial from. I downloaded it and printed it placed
in a nice three ring binder and study a little bit every night. The tutorial
at the above link has the issue I orginally mentioned in section 3 An
Informal Intoduction  to Python. I did not type in the whole section because
I didn't want everyone to have to read through a lot of  newbie steps that
they were probably already aware of. It is on page 5 of 11 if you print it
out on 8.5x11 paper. I have copyied it from the web page below.
In interactive mode, the last printed expression is assigned to the variable
_. This means that when you are using Python as a desk calculator, it is
somewhat easier to continue calculations, for example:

>>> tax = 17.5 / 100
>>> price = 3.50
>>> price * tax
0.6125
>>> price + _
4.1125
>>> round(_, 2)
4.11

This variable should be treated as read-only by the user. Don't explicitly
assign a value to it -- you would create an independent local variable with
the same name masking the built-in variable with its magic behavior.

What I ended up with when I did that was off by a miniscule amount and I was
just wondering if it was do to editting needs (rounding numbers is not
unusal in thing)
or if I had done something wrong.  I am not trying to trash anyone or there
stuff. I am a newbie at this and go by this ideal:
It is a lot easier to ask stupid quetions then it is to deal with stupid
mistakes.


However it is very possible that I made a stupid mistake. I intend to keep
plugging away at learning this and everyone has been very helpful but
despite my best efforts I will probaply contiue to have to ask some stupid
questions.


--
Thanks,
Brendhan









More information about the Python-list mailing list