(This page has no text content)
Intro to Python for Computer Science and Data Science Learning to Program with AI, Big Data and the Cloud by Paul Deitel & Harvey Deitel ®
(This page has no text content)
Deitel Series Page How To Program Series Android How to Program, 3/E C++ How to Program, 10/E C How to Program, 8/E Java How to Program, Early Objects Version, 11/E Java How to Program, Late Objects Version, 11/E Internet & World Wide Web How to Program, 5/E Visual Basic® 2012 How to Program, 6/E Visual C#® How to Program, 6/E REVEL™ Interactive Multimedia REVEL™ for Deitel Java™ ® ™ ™ ™
VitalSource Web Books http://bit.ly/DeitelOnVitalSource Android How to Program, 2/E and 3/E C++ How to Program, 9/E and 10/E Java How to Program, 10/E and 11/E Simply C++: An App-Driven Tutorial Approach Simply Visual Basic® 2010: An App-Driven Approach, 4/E Visual Basic® 2012 How to Program, 6/E Visual C#® How to Program, 6/E Visual C#® 2012 How to Program, 5/E Deitel® Developer Series Android 6 for Programmers: An App-Driven Approach, 3/E C for Programmers with an Introduction to C11 C++11 for Programmers C# 6 for Programmers ™ ™ ™
Java for Programmers, 4/E JavaScript for Programmers Swift for Programmers LiveLessons Video Training http://deitel.com/books/LiveLessons/ Android 6 App Development Fundamentals, 3/E C++ Fundamentals Java SE 8 Fundamentals, 2/E Java SE 9 Fundamentals, 3/E C# 6 Fundamentals C# 2012 Fundamentals JavaScript Fundamentals Swift Fundamentals To receive updates on Deitel publications, Resource Centers, training courses, partner offers and more, please join the Deitel communities on ™ ™ ™ ™ ™ ™
Facebook —http://facebook.com/DeitelFan Twitter —@deitel LinkedIn —http://linkedin.com/company/deitel-&- associates YouTube™—http://youtube.com/DeitelTV Instagram —http://instagram.com/DeitelFan and register for the free Deitel Buzz Online e-mail newsletter at: http://www.deitel.com/newsletter/subscribe.html To communicate with the authors, send e-mail to: deitel@deitel.com For information on programming-languages corporate training seminars offered by Deitel & Associates, Inc. worldwide, write to deitel@deitel.com or visit: http://www.deitel.com/training/ For continuing updates on Pearson/Deitel publications visit: http://www.deitel.com http://www.pearson.com/deitel ® ® ® ® ®
(This page has no text content)
Intro to Python for Computer Science and Data Science ®
Senior Vice President, Courseware Portfolio Management: Marcia J. Horton Director, Portfolio Management: Engineering, Computer Science & Global Editions: Julian Partridge Executive Higher Ed Portfolio Management: Tracy Johnson (Dunkelberger) Portfolio Management Assistant: Meghan Jacoby Managing Content Producer: Scott Disanno Content Producer: Carole Snyder Rights and Permissions Manager: Ben Ferrini Inventory Manager: Bruce Boundy Product Marketing Manager: Yvonne Vannatta Field Marketing Manager: Demetrius Hall Marketing Assistant: Jon Bryant Cover Designer: Paul Deitel, Harvey Deitel, Chuti Prasertsith Cover Art: ©Denel/Shutterstock
Copyright ©2020 Pearson Education, Inc. All rights reserved. Manufactured in the United States of America. This publication is protected by copyright, and permission should be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permissions, request forms and the appropriate contacts within the Pearson Education Global Rights & Permissions department, please visit http://www.pearsoned.com/permissions. Many of the designations by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and the publisher was aware of a trademark claim, the designations have been printed in initial caps or all caps. The authors and publisher of this book have used their best efforts in preparing this book. These efforts include the development, research, and testing of the theories and programs to determine their effectiveness. The authors and publisher make no warranty of any kind, expressed or implied, with regard to these programs or to the documentation contained in this book. The authors and publisher shall not be liable in any event for incidental or consequential damages in connection with, or arising out of, the furnishing, performance, or use of these programs.
Deitel and the double-thumbs-up bug are registered trademarks of Deitel and Associates, Inc. Library of Congress Cataloging-in-Publication Data On file ISBN-10: 0-13-540467-3 ISBN-13: 978-0-13-540467-6
Intro to Python for Computer Science and Data Science Learning to Program with AI, Big Data and the Cloud Paul Deitel Harvey Deitel ®
In Memory of Marvin Minsky, a founding father of artificial intelligence It was a privilege to be your student in two artificial- intelligence graduate courses at M.I.T. You inspired your students to think beyond limits. Harvey Deitel
Contents 1. Preface xix 2. Before You Begin xlv 1. 1 Introduction to Computers and Python 1 1. 1.1 Introduction 2 2. 1.2 Hardware and Software 3 1. 1.2.1 Moore’s Law 4 2. 1.2.2 Computer Organization 4 3. 1.3 Data Hierarchy 6 4. 1.4 Machine Languages, Assembly Languages and High-Level Languages 9 5. 1.5 Introduction to Object Technology 10 6. 1.6 Operating Systems 13 7. 1.7 Python 16 8. 1.8 It’s the Libraries! 18 1. 1.8.1 Python Standard Library 18 2. 1.8.2 Data-Science Libraries 18 9. 1.9 Other Popular Programming Languages 20 10. 1.10 Test-Drive: Using IPython and Jupyter Notebooks 21
1. 1.10.1 Using IPython Interactive Mode as a Calculator 21 2. 1.10.2 Executing a Python Program Using the IPython Interpreter 23 3. 1.10.3 Writing and Executing Code in a Jupyter Notebook 24 11. 1.11 Internet and World Wide Web 29 1. 1.11.1 Internet: A Network of Networks 29 2. 1.11.2 World Wide Web: Making the Internet User- Friendly 30 3. 1.11.3 The Cloud 30 4. 1.11.4 Internet of Things 31 12. 1.12 Software Technologies 32 13. 1.13 How Big Is Big Data? 33 1. 1.13.1 Big Data Analytics 38 2. 1.13.2 Data Science and Big Data Are Making a Difference: Use Cases 39 14. 1.14 Intro to Data Science: Case Study—A Big-Data Mobile Application 40 2. 2 Introduction to Python Programming 49 1. 2.1 Introduction 50 2. 2.2 Variables and Assignment Statements 50 3. 2.3 Arithmetic 52 4. 2.4 Function print and an Intro to Single- and Double-Quoted Strings 56
5. 2.5 Triple-Quoted Strings 58 6. 2.6 Getting Input from the User 59 7. 2.7 Decision Making: The if Statement and Comparison Operators 61 8. 2.8 Objects and Dynamic Typing 66 9. 2.9 Intro to Data Science: Basic Descriptive Statistics 68 10. 2.10 Wrap-Up 70 3. 3 Control Statements and Program Development 73 1. 3.1 Introduction 74 2. 3.2 Algorithms 74 3. 3.3 Pseudocode 75 4. 3.4 Control Statements 75 5. 3.5 if Statement 78 6. 3.6 if…else and if…elif…else Statements 80 7. 3.7 while Statement 85 8. 3.8 for Statement 86 1. 3.8.1 Iterables, Lists and Iterators 88 2. 3.8.2 Built-In range Function 88 9. 3.9 Augmented Assignments 89 10. 3.10 Program Development: Sequence-Controlled Repetition 90 1. 3.10.1 Requirements Statement 90 2. 3.10.2 Pseudocode for the Algorithm 90 3. 3.10.3 Coding the Algorithm in Python 91 4. 3.10.4 Introduction to Formatted Strings 92
11. 3.11 Program Development: Sentinel-Controlled Repetition 93 12. 3.12 Program Development: Nested Control Statements 97 13. 3.13 Built-In Function range: A Deeper Look 101 14. 3.14 Using Type Decimal for Monetary Amounts 102 15. 3.15 break and continue Statements 105 16. 3.16 Boolean Operators and, or and not 106 17. 3.17 Intro to Data Science: Measures of Central Tendency— Mean, Median and Mode 109 18. 3.18 Wrap-Up 111 4. 4 Functions 119 1. 4.1 Introduction 120 2. 4.2 Defining Functions 120 3. 4.3 Functions with Multiple Parameters 123 4. 4.4 Random-Number Generation 125 5. 4.5 Case Study: A Game of Chance 128 6. 4.6 Python Standard Library 131 7. 4.7 math Module Functions 132 8. 4.8 Using IPython Tab Completion for Discovery 133 9. 4.9 Default Parameter Values 135 10. 4.10 Keyword Arguments 136 11. 4.11 Arbitrary Argument Lists 136 12. 4.12 Methods: Functions That Belong to Objects 138 13. 4.13 Scope Rules 138 14. 4.14 import: A Deeper Look 140 15. 4.15 Passing Arguments to Functions: A Deeper Look 142
16. 4.16 Function-Call Stack 145 17. 4.17 Functional-Style Programming 146 18. 4.18 Intro to Data Science: Measures of Dispersion 148 19. 4.19 Wrap-Up 150 5. 5 Sequences: Lists and Tuples 155 1. 5.1 Introduction 156 2. 5.2 Lists 156 3. 5.3 Tuples 161 4. 5.4 Unpacking Sequences 163 5. 5.5 Sequence Slicing 166 6. 5.6 del Statement 169 7. 5.7 Passing Lists to Functions 171 8. 5.8 Sorting Lists 172 9. 5.9 Searching Sequences 174 10. 5.10 Other List Methods 176 11. 5.11 Simulating Stacks with Lists 178 12. 5.12 List Comprehensions 179 13. 5.13 Generator Expressions 181 14. 5.14 Filter, Map and Reduce 182 15. 5.15 Other Sequence Processing Functions 185 16. 5.16 Two-Dimensional Lists 187 17. 5.17 Intro to Data Science: Simulation and Static Visualizations 191 1. 5.17.1 Sample Graphs for 600, 60,000 and 6,000,000 Die Rolls 191
2. 5.17.2 Visualizing Die-Roll Frequencies and Percentages 193 18. 5.18 Wrap-Up 199 6. 6 Dictionaries and Sets 209 1. 6.1 Introduction 210 2. 6.2 Dictionaries 210 1. 6.2.1 Creating a Dictionary 210 2. 6.2.2 Iterating through a Dictionary 212 3. 6.2.3 Basic Dictionary Operations 212 4. 6.2.4 Dictionary Methods keys and values 214 5. 6.2.5 Dictionary Comparisons 216 6. 6.2.6 Example: Dictionary of Student Grades 217 7. 6.2.7 Example: Word Counts 218 8. 6.2.8 Dictionary Method update 220 9. 6.2.9 Dictionary Comprehensions 220 3. 6.3 Sets 221 1. 6.3.1 Comparing Sets 223 2. 6.3.2 Mathematical Set Operations 225 3. 6.3.3 Mutable Set Operators and Methods 226 4. 6.3.4 Set Comprehensions 228 4. 6.4 Intro to Data Science: Dynamic Visualizations 228 1. 6.4.1 How Dynamic Visualization Works 228
Comments 0
Loading comments...
Reply to Comment
Edit Comment