%s %x %0.2f %04d

Steve Juranich sjuranic at condor.ee.washington.edu
Fri Sep 8 17:42:20 EDT 2000


>>> print "%s, %x, %04d, %0.2f" % ('Hi', 16, 2, float(2))    
Hi, 10, 0002, 2.00

You should read up on the docs for the "print" statement.  Post any
questions you have if the docs don't make sense.

----------------------------------------------------------------------
Stephen W. Juranich                         sjuranic at ee.washington.edu
Electrical Engineering         http://students.washington.edu/sjuranic
University of Washington             http://rcs.ee.washington.edu/ssli


On Fri, 8 Sep 2000, Brendhan Horne wrote:

> In the beginners instruction manual it states:
> There are other letters that can be placed after the % markers. Some of
> those include:
> %s- for string
> %x- for hexadecimal number
> %0.2f- for a real number with a maximum of 2 decimal places
> %04d- pad the number out to 4 digits with 0's
> 
> 
> That is nice but it gives no examples of how to use them. I tried some of
> the basics
> >>> print 7%s2
> Got an error
> >>> print 7 %s 2
> Got an error
> So if someone could show me some basic one liners that use the modulus with
> the suffix I would appreciate it.  Remember when you do this you are dealing
> with someone who has no knowledge of computer language.
> 
> 
> --
> Thanks,
> Brendhan
> 
> 
> 
> 
> 




More information about the Python-list mailing list