[Tutor] Just wondering
Marcel Preda
marcel@punto.it
Thu, 19 Oct 2000 12:40:10 +0200 (CEST)
On Thu, 19 Oct 2000 Pollock974@aol.com wrote:
> Hello,
> I am a complete newbie at Python and i have a couple of questions. First
> of all i bought a book called "Teach Yourself Python in 24 Hours" by Ivan
> Van Laningham. I was just wondering if anybody's read it and if its worth
> reading. Second, this is a program for printing the ascii table.
>
> 1. #!/usr/local/bin/python
> 2.
> 3. i = 0
> 4. while i < 256:
> 5. print chr(i),
> 6. if i != 0 and i % 8 == 0:
> 7. print
> 8. i = i +1
>
> Now i have 2 questions. First of all i may be wrong but isn't the 1st
> line a location on a Unix platform? Im running Windoze 98 and was wondering
> if i needed that line of code. Second, when i look at the code it seems that
> the 6th and 7th line aren't needed, but when i run it without it, it prints 1
> character on each line. I was wondering how that tells python to print more
> than 1 character on a line. Now this isnt a life or death situation, it's
> just been on my mind. I looked in the book but i couldnt find anything. Any
> help would be greatly appreciated.
>
> _______________________________________________
> Tutor maillist - Tutor@python.org
> http://www.python.org/mailman/listinfo/tutor
>
#1
YES(is a Unix platform)
you dont need it, but it will not do semething wrong
#2
looks like after every 8 characters the script insert a newLine,
so if you don't need...
Abot MORE THAN ONE (#3)
By default `print' add a `\n'
You have tu use `,' if want to skip `\n'
>>> for i in range(0,1):
... print 'a'
... print 'b'
...
a
b
>>> for i in range(0,1):
... print 'a',
... print 'b'
...
a b
PM
__
To be or not to be.
-- Shakespeare
To do is to be.
-- Nietzsche
To be is to do.
-- Sartre
Do be do be do.
-- Sinatra
___