[Courses] [python] Lesson 1: Hello world
Holly Bostick
aka.motub at gmail.com
Wed Jun 22 18:24:16 UTC 2011
Hey, Scott, thanks a lot! I'm sending this back to the list as I think was
intended (your original was sent only to me, stupid GMail :P ).
So my revised Hello World script looks like this (also with a little "+"
fillip from Akkana :) ):
print "Hello, World!"
name = raw_input("What is your name?\n")
print "Hello,", name+"!"
with the result:
Hello, World!
What is your name?
Holly
Hello, Holly!
I know it's "just" the traditional "Hello, World!" script that all
programming courses start with, but I must admit I'm pleased as punch...
this little script does exactly what it's supposed to, and formats the
output exactly as I want it to. A rousing success, imo :) .
Onwards and upwards!
Holly
2011/6/22 Scott Newson <scott.g.newson at gmail.com>
> Holly,
>
> > So now I
> > want to know-- how do you know when the command has 'ended' ? Is it just
> by
> > putting a hard return to the next line, as in the extended example that
> > includes user input?
> I've heard that python uses 'whitespace' to separate commands, I guess that
> this is an example of that. To have a single command over multiple lines, it
> looks like one adds a '\' character at the end of a line. ie
> >>> print "Hello \
> >>> world"
>
> > If so, what if I wanted to print two lines that had a
> > hard return between them? For example, if I wanted the answer to "What is
> > your name" to be printed on the next line (which would look better)? I
> > imagine there's an escape character to signify that....?
> The escape character here is '\n' ie
> >>> print "Hello \n world"
>
> I have also just use two separate print statements if it makes sense to me
> when programming.
>
> Scott
>
More information about the Courses
mailing list