Chapter 16. The Python Programming Language

In This Chapter

  • Manipulating numbers

  • Working with strings of characters

  • Making use of lists

  • Uncovering the fundamental structure of a Python program

SPSS has added Python — a general-purpose programming language — that can be used as a SPSS scripting language. Chapter 17 is about using Python inside SPSS, but this chapter is about the Python programming language itself. If you're not a programmer, don't worry; Python is famous for being easy to learn. And you might think it's named after a snake, but it isn't. It's named after Monty Python's Flying Circus. I just thought I'd mention that in case you thought things were going to get serious. And now for something completely different.

Instructing Python: You Type It In and Python Does It

If you give Python an instruction that it understands, it will obey the instruction and do something. It's very obliging that way. But you have to be specific when you tell it what you want it to do.

If you want a Python of your own, outside of the one that comes with SPSS, you can download and install one from the Internet for free. By playing with your own Python, you can see how the examples in this chapter work. The only way to really get to know a programming language is to fiddle around with it and write some programs of your own. Sometimes you get great insight into programming from finding out what doesn't work.

Python is an interpreter. That is, instead of taking your set of program instructions and translating ...

Get SPSS For Dummies®, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.