very newbie questions

Kragen Sitaker kragen at dnaco.net
Sat Sep 30 22:03:15 EDT 2000


In article <20000930161649.06131.00000281 at ng-fy1.aol.com>,
AquaRock7 <aquarock7 at aol.com> wrote:
>How do you write an exponent sign in python (ie how do u write 16 x 16 in
>exponential form?)

16L ** 16 is sixteen (long) to the sixteenth power; I think you're
asking how to write 16 squared, which is 16 ** 2.

>WHat does the '%' operation do?

GIves you the remainder from division.  100 % 17 is 15, because 17 * 5
is 85, which is 15 less than 100.  This makes more sense if you know
how to do long division by hand.

I recommend http://www.python.org/doc/current/ref/binary.html and
thereabouts.

>One more thing...  How do you turn a string into numerical data to do math on
>(I have to use the raw_input() command, b/c they enter a # in hexadecimal) then
>turn the numerical data back into a string?

int(), long(), float(), and complex() turn strings into different kinds
of numbers (see
http://www.python.org/doc/current/lib/typesnumeric.html), and str()
turns almost anything, including numbers, into a string.
-- 
<kragen at pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Perilous to all of us are the devices of an art deeper than we ourselves
possess.
                -- Gandalf the Grey [J.R.R. Tolkien, "Lord of the Rings"]





More information about the Python-list mailing list