Before starting to write programs, you’ll need to learn how to experiment with the Python shell. For now, you can think of the Python shell as a way to peer within running Python code. It places you inside of a running instance of Python, into which you can feed programming code; at the same time, Python will do what you have asked it to do and will show you a little bit about how it responds to its environment. Because running programs often have a context — things that you as the programmer have tailored to your needs — it is an advantage to have the shell because it lets you experiment with the context you have created. Now that you have installed Python version 3.1, you can begin to experiment with the shell’s basic behavior. For starters, type in some text: > > > ”Hello World. You will never see this.”
Although Python didn’t technically do anything with your words, it did give some indication that it read them. Python indicated this by displaying the text you entered (known as a string ) in quotes. A string is a data type, and each data type is displayed differently by Python. As you progress through this book, you will see the different ways Python displays each one. Beginning to Use Python — Strings At this point, you should feel free to experiment with using the shell’s basic behavior. Type some text, in quotes; for starters, you could type the following: > > > “This text really won’t do anything” “This text really won’t do anything”
However, you can see that Python indicated that it saw what you entered. It showed you the text you entered, and it displayed it in the manner it will always display a string — in quotes. As you learn about other data types, you’ll find that Python has a way of displaying each one differently. Please check back tomorrow for the second part of this series.
blog comments powered by Disqus |