Difference between revisions of "Python:Hello World"

From Progzoo
Jump to: navigation, search
 
Line 5: Line 5:
  
 
</p><prog>
 
</p><prog>
print "Hello world"
 
</prog></question>
 
 
Caution: The above code is only valid for Python 2.x. In Python 3.x, <code>print</code> has become a function and it is necessary to enclose the argument in parentheses:
 
<pre>
 
 
print("Hello world")
 
print("Hello world")
</pre>
+
</prog></question>
This version of the code will also work on 2.x, in the case when there is only one argument.
+

Latest revision as of 14:11, 11 December 2009

The number one program is Hello World. This program prints the string "Hello World".

[Font] [Default] [Show] [Resize] [History] [Profile]