[Tutor] Hello World.

Lloyd Kvam pythontutor@venix.com
Sat, 16 Mar 2002 20:32:50 -0500


I didn't mean to insult you.  Some of the queries come from people who are
fairly lost at first.

Spam wrote:

> Er, I know to type 'print'... But I was just intrigued, first by the website
> (which may be old, or merely inaccurate), but more by the fact I couldn't
> see why the Python Shell would be different.
> 
> Thanks for your reply.
> 
> Grail.
> 
> ----- Original Message -----
> From: "Lloyd Kvam" <pythontutor@venix.com>
> To: "Grail" <python@nzpagans.8m.com>
> Cc: <tutor@python.org>
> Sent: Sunday, March 17, 2002 2:15 AM
> Subject: Re: [Tutor] Hello World.
> 
> 
> 
>>In the Python Shell, results from expressions will be displayed if you
>>do not assign the result to a variable.  In a program, results from
>>an expression are simply discarded if the program does not save the
>>result to a variable.
>>
>>A shell example:
>> >>> 2+2
>>4
>> >>> a = 2+2
>> >>>
>>
>>In a program, the first line
>>2+2
>>will get python to calculate a result of 4.  HOWEVER, since the program
>>gives no instructions as to what to do with that result, Python will
>>simply discard it.  Effectively, the shell is a Python program the will
>>print results before the result is discarded.
>>
>>Your program needs to say:
>>print "Hello World"
>>
>>Grail wrote:
>>
>>
>>>It says at http://www.geocities.com/SiliconValley/2072/python.htm
>>>That all you need to type to display "Hello, World." is:
>>>"Hello, World."
>>>(no 'print' required)
>>>
>>>In the python shell, this worked!
>>>Saved as a program, it didn't.
>>>
>>>So, why is there a difference between what you type in directly to the
>>>Python Shell, and what you save as a program?
>>>
>>>
>>>
>>>_______________________________________________
>>>Tutor maillist  -  Tutor@python.org
>>>http://mail.python.org/mailman/listinfo/tutor
>>>
>>>
>>>
>>
>>--
>>Lloyd Kvam
>>Venix Corp.
>>1 Court Street, Suite 378
>>Lebanon, NH 03766-1358
>>
>>voice:
>>603-443-6155
>>fax:
>>801-459-9582
>>
>>
>>_______________________________________________
>>Tutor maillist  -  Tutor@python.org
>>http://mail.python.org/mailman/listinfo/tutor
>>
>>
> 
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
> 
> 


-- 
Lloyd Kvam
Venix Corp.
1 Court Street, Suite 378
Lebanon, NH 03766-1358

voice: 
603-443-6155
fax: 
801-459-9582