Back to List

Making A Statement

Posted by Neville Dinning
10
Aug 24, 2016
44 Views
No doubt you have seen how just about every programming language or web page building course gets the beginner to print out "Hello World". And I guess that you are wondering just how to do that in Python. Well here goes! First get your Interactive console up. It can either be in the Python shell or in the IDLE environment. At the prompt (usually like this >>>), type in print("Hello World") and then press the enter key. If all goes well you should see the magic words Hello World printed out on the next line. So, what's happening here? The command 'print' is one of the few built in statements in python. That statement expects to receive something that will be enclosed in a pair of brackets to print out. Because "Hello World" is a piece of text, it has to be in quotes for the interpreter to be able to work out what to print. If you want to see what happens when you forget the quotes just try print(Hello World). Go ahead and experiment with the print statement. Try print(89) or maybe print(5 + 6). print is reserved keyword in python, and is actually a function that can do a whole lot more than just print to the screen. But that is for later. The value in the brackets, or argument, is passed to the print statement and if all is correct the interpreter will process the statement and the argument and do just what is asked. (ie: print the result of the argument to the screen in this case). Any questions? Ask them below as a comment and see what answers you get.
Comments
avatar
To join the discussion, simply log in with your Google or Facebook account.

How it works:

  1. Click one of the login buttons above
  2. You'll be redirected to the authorization page
  3. After logging in, you'll be returned to the forum
  4. Your guest account will be automatically created if it's your first time

© APSense LTD. All-in-One Business Hub. All Rights Reserved. This forum service is provided by APSense.com