文档介绍:Introduction to
Computation and
Programming Using Python
(Spring 2013 Edition)
John V. Guttag
The MIT Press Cambridge,
Massachusetts London,
England
© 2013 Massachusetts Institute of Technology
All rights reserved. No part of this book may be reproduced in any form by any
electronic or mechanical means (including photocopying, recording, or information
storage and retrieval) without permission in writing from the publisher.
MIT Press books may be purchased at special quantity discounts for business or
sales promotional use. For information, please email
special_******@ or write to Special Sales Department, The MIT
Press, 55 Hayward Street, Cambridge, MA 02142.
Printed and bound in the United States of America.
ISBN: 978-0-262-51963-2
Library of Congress Control Number: 2012953229
10 9 8 7 6 5 4 3 2 1
Cover photograph: Antelope Canyon, courtesy of Freda Durand.
To my family:
Olga
David
Andrea
Michael
Mark
Addie
IV
CONTENTS
PREFACE ..................................... .................................... ... ix
SPRING 2013 E DITION ........................ ............................... ..... xi
ACKNOWLEDGMENTS.................................................. ........ ... xii
GETTING STARTED ............ 1
2 INTR ODUCTION TO .............. 7
PYTHON ............................................
.......................... 8
2. 1 The Basic Element of Python.. . ....................
...9
Objects, expressions, and numerical types
... 11
21 2 Variables and assignment .............................
IDLE ........................................................................................... 13
Branching Programs .......................................... ..................... .......... 13
Type Str and Input.....................