O'Reilly logo

Raspberry Pi For Dummies by Mike Cook, Sean McManus

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Entering Your First Python Commands

When you start IDLE, a window opens with text at the top that looks something like Figure 12-1.

This is the Python shell, and the three arrows are your prompt, which means Python is ready for you to enter a command. You can test this by entering the license() command, which shows you a history of Python before displaying the terms and conditions of using it. If you don’t want to get bogged down in legalese, abort by pressing q and then pressing Enter when prompted.

One of the most basic commands in any programming language is the one that tells the computer to put some text on the screen. In Python (and some other languages too), this command is print, and you use it like this:

>>> print “hello”

hello

>>>

Whatever you type in the quotes after the print command is “printed” on the screen, and Python then returns you to the prompt so you can enter another command.

9781118554234-fg1201.tif

Copyright © 2001-2012 Python Software Foundation; All Rights Reserved

Figure 12-1: The Python shell, just after it opens.

warning_bomb.eps Like the Linux shell, Python is case-sensitive, which means it won’t work if you use capital letters where you shouldn’t. The command print must be entered in lowercase; otherwise, Python tells you you’ve made a syntax error, which means you’re using a command incorrectly. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required