ENGLISH

Introduction to Python Programming

Book information

Publisher
CRC
Year
2019
ISBN
9780815394372
Language
english
Format
PDF
Filesize
14 MB (14792199 bytes)
Pages
465\465
Time added
2018-12-06 12:35:01

Description

This book presents an intuitive approach to the concepts of Python Programming for students. It is appropriate for courses generally known as “Introduction to Python Programming.” We have tried to write a book that assists students in discovering the power of Python programming. We have taken into account the reality that students taking “Introduction to Python Programming” course are likely to come from a variety of disciplines. In addition to Computer Science majors, there tend to be students from other majors like other engineering streams, physics, chemistry, biology, environmental science, geography, economics, psychology and business. This book differs from traditional texts not only in its philosophy but also in its overall focus, level of activities, development of topics, and attention to programming details. The emphasis is on understanding Python programming concepts. Reading a programming book is different from reading a newspaper or a novel. Don’t be discouraged if you have to read a passage more than once in order to understand it. We recommend that you keep this book for reference purposes after you finish working through the course. Because you will likely forget some of the specific details of Python programming language, the book will serve as a useful reminder. Students will appreciate the many programming examples within the text. Programs are carefully selected to bring the theoretical concepts to fruition. Our aim is to get the reader to productivity as quickly as possible without sacrificing the overall flow quality. In fact, if you are a novice programmer, with some dedication and hard work you should be able to learn Python Programming as your first programming language. As we introduce each new feature of the language, we usually provide a complete program as an example to illustrate the feature. Just as a picture is worth a thousand words, so is a properly chosen programming example. We present the material in a way to encourage student thinking and we show students how to generalize key concepts once they are introduced, which can be used to solve real-world problems. Programming questions that accompany the end of each chapter are based on worked examples which help students to gain solid knowledge of the basics and assess their own level of understanding before moving on. Students are highly encouraged to solve these programs to gain a solid hold on Python programming language. This book takes you through step by step process of learning the Python programming language. Each line of the code is marked with numbers and is explained in detail. In this book all the names of variables, strings, lists, dictionaries, tuples, functions, methods and classes consist of several natural words and in the explanation part they are written in italics to indicate the readers that they are part of programming code and to distinguish them from normal words. This programming style of using readable natural names makes the reading of code lot easier and prevents programming errors. Learning outcome component is mentioned at the beginning of each chapter that calls the attention of the readers to important items in the chapter. A summary of important concepts appears at the end of each chapter. We hope that students using the book will come away with an appreciation of the beauty, power, and tremendous utility of Python programming language and that they will have fun along the way. Cover......Page 1 Half Title......Page 2 Title Page......Page 4 Copyright Page......Page 5 Dedication......Page 6 Table of Contents......Page 8 Preface......Page 14 Acknowledgment......Page 18 Authors......Page 20 1.1 What Is a Program?......Page 22 1.2.1 Machine Language......Page 23 1.2.3 High-Level Language......Page 24 1.3 Software Development......Page 26 1.4 History of Python Programming Language......Page 28 1.5 Thrust Areas of Python......Page 29 1.5.1 Academia......Page 30 1.5.5 Data Analysis......Page 31 1.5.10 Cloud Computing......Page 32 1.5.14 Python Stack in Industry......Page 33 1.6 Installing Anaconda Python Distribution......Page 34 1.7 Installing PyCharm IDE to Set Up a Python Development Environment......Page 37 1.8 Creating and Running Your First Python Project......Page 40 1.9 Installing and Using Jupyter Notebook......Page 44 1.9.1 Starting Jupyter Notebook......Page 45 1.10 Open Source Software......Page 48 1.10.1 Why Do People Prefer Using Open Source Software?......Page 49 1.10.3 Open Source Licenses......Page 50 Multiple Choice Questions......Page 53 Review Questions......Page 55 2.1 Identifiers......Page 56 2.3 Statements and Expressions......Page 57 2.4.2 Assigning Values to Variables......Page 58 2.5 Operators......Page 59 2.5.1 Arithmetic Operators......Page 60 2.5.2 Assignment Operators......Page 61 2.5.3 Comparison Operators......Page 63 2.5.4 Logical Operators......Page 64 2.5.5 Bitwise Operators......Page 65 2.6 Precedence and Associativity......Page 68 2.7.3 Strings......Page 69 2.8 Indentation......Page 70 2.10 Reading Input......Page 71 2.11.1 str.format() Method......Page 72 2.11.2 f-strings......Page 74 2.12.1 The int() Function......Page 75 2.12.3 The str() Function......Page 76 2.12.5 The complex() Function......Page 77 2.12.8 The oct() Function......Page 78 2.14 Dynamic and Strongly Typed Language......Page 79 2.15 Summary......Page 80 Multiple Choice Questions......Page 81 Review Questions......Page 86 3: Control Flow Statements......Page 88 3.1 The if Decision Control Flow Statement......Page 89 3.2 The if…else Decision Control Flow Statement......Page 90 3.3 The if…elif…else Decision Control Statement......Page 92 3.4 Nested if Statement......Page 94 3.5 The while Loop......Page 95 3.6 The for Loop......Page 100 3.7 The continue and break Statements......Page 102 3.8.2 Exceptions......Page 105 3.8.3 Exception Handling Using try…except…finally......Page 106 3.9 Summary......Page 110 Multiple Choice Questions......Page 111 Review Questions......Page 114 4.1 Built-In Functions......Page 116 4.2 Commonly Used Modules......Page 118 4.3 Function Definition and Calling the Function......Page 120 4.4 The return Statement and void Function......Page 124 4.5 Scope and Lifetime of Variables......Page 127 4.6 Default Parameters......Page 129 4.7 Keyword Arguments......Page 130 4.8 *args and **kwargs......Page 131 4.9 Command Line Arguments......Page 133 Multiple Choice Questions......Page 134 Review Questions......Page 138 5.1 Creating and Storing Strings......Page 140 5.2 Basic String Operations......Page 141 5.2.2 Built-In Functions Used on Strings......Page 143 5.3 Accessing Characters in String by Index Number......Page 144 5.4 String Slicing and Joining......Page 145 5.4.1 Specifying Steps in Slice Operation......Page 147 5.4.3 Split Strings Using split() Method......Page 148 5.4.5 String Traversing......Page 149 5.5 String Methods......Page 152 5.6 Formatting Strings......Page 159 5.6.1 Format Specifiers......Page 161 5.6.2 Escape Sequences......Page 162 5.6.4 Unicodes......Page 163 Multiple Choice Questions......Page 164 Review Questions......Page 167 6.1 Creating Lists......Page 170 6.2.1 The list() Function......Page 172 6.3 Indexing and Slicing in Lists......Page 173 6.3.1 Modifying Items in Lists......Page 174 6.4 Built-In Functions Used on Lists......Page 176 6.5 List Methods......Page 177 6.5.1 Populating Lists with Items......Page 179 6.5.2 Traversing of Lists......Page 180 6.5.3 Nested Lists......Page 188 6.6 The del Statement......Page 190 Multiple-Choice Questions......Page 191 Review Questions......Page 194 7.1 Creating Dictionary......Page 196 7.2 Accessing and Modifying key:value Pairs in Dictionaries......Page 199 7.3 Built-In Functions Used on Dictionaries......Page 200 7.4 Dictionary Methods......Page 202 7.4.1 Populating Dictionaries with key:value Pairs......Page 204 7.4.2 Traversing of Dictionary......Page 206 Multiple Choice Questions......Page 214 Review Questions......Page 219 8.1 Creating Tuples......Page 222 8.2 Basic Tuple Operations......Page 224 8.2.1 The tuple() Function......Page 225 8.3 Indexing and Slicing in Tuples......Page 226 8.4 Built-In Functions Used on Tuples......Page 228 8.5 Relation between Tuples and Lists......Page 229 8.6 Relation between Tuples and Dictionaries......Page 230 8.7 Tuple Methods......Page 231 8.7.2 Traversing of Tuples......Page 232 8.7.3 Populating Tuples with Items......Page 233 8.9 Sets......Page 237 8.10 Set Methods......Page 239 8.10.1 Traversing of Sets......Page 240 8.11 Frozenset......Page 242 Multiple Choice Questions......Page 243 Review Questions......Page 248 9: Files......Page 250 9.1 Types of Files......Page 251 9.1.1 File Paths......Page 252 9.1.2 Fully Qualified Path and Relative Path......Page 253 9.2.1 Creating and Opening Text Files......Page 254 9.2.2 File close() Method......Page 256 9.2.3 Use of with Statements to Open and Close Files......Page 258 9.3 File Methods to Read and Write Data......Page 260 9.4 Reading and Writing Binary Files......Page 268 9.5 The Pickle Module......Page 270 9.6 Reading and Writing CSV Files......Page 272 9.7 Python os and os.path Modules......Page 278 9.8 Summary......Page 282 Multiple Choice Questions......Page 283 Review Questions......Page 286 10.1 Using Special Characters......Page 288 10.1.2 Using Parentheses in Regular Expressions......Page 293 10.2.1 Compiling Regular Expressions Using compile() Method of re Module......Page 294 10.2.2 Match Objects......Page 295 10.4 Regular Expression with glob Module......Page 303 Multiple Choice Questions......Page 305 Review Questions......Page 308 11.1 Classes and Objects......Page 310 11.2 Creating Classes in Python......Page 312 11.3 Creating Objects in Python......Page 314 11.4 The Constructor Method......Page 315 11.5 Classes with Multiple Objects......Page 318 11.5.1 Using Objects as Arguments......Page 322 11.5.2 Objects as Return Values......Page 324 11.6 Class Attributes versus Data Attributes......Page 327 11.7 Encapsulation......Page 328 11.7.1 Using Private Instance Variables and Methods......Page 330 11.8 Inheritance......Page 332 11.8.1 Accessing the Inherited Variables and Methods......Page 333 11.8.2 Using super() Function and Overriding Base Class Methods......Page 335 11.8.3 Multiple Inheritances......Page 338 11.8.4 Method Resolution Order (MRO)......Page 341 11.9 The Polymorphism......Page 349 11.9.1 Operator Overloading and Magic Methods......Page 352 11.10 Summary......Page 356 Multiple Choice Questions......Page 357 Review Questions......Page 359 12.1.1 Lambda......Page 362 12.1.2 Iterators......Page 363 12.1.3 Generators......Page 364 12.1.4 List Comprehensions......Page 365 12.2 JSON and XML in Python......Page 367 12.2.1 Using JSON with Python......Page 368 12.2.2 Using Requests Module......Page 374 12.2.3 Using XML with Python......Page 376 12.3 NumPy with Python......Page 380 12.3.1 NumPy Arrays Creation Using array() Function......Page 381 12.3.2 Array Attributes......Page 382 12.3.3 NumPy Arrays Creation with Initial Placeholder Content......Page 383 12.3.4 Integer Indexing, Array Indexing, Boolean Array Indexing, Slicing and Iterating in Arrays......Page 385 12.3.5 Basic Arithmetic Operations on NumPy Arrays......Page 388 12.3.6 Mathematical Functions in NumPy......Page 389 12.3.7 Changing the Shape of an Array......Page 390 12.3.8 Stacking and Splitting of Arrays......Page 391 12.3.9 Broadcasting in Arrays......Page 392 12.4 Pandas......Page 395 12.4.1 Pandas Series......Page 396 12.4.2 Pandas DataFrame......Page 401 12.5 Altair......Page 419 12.6 Summary......Page 430 Multiple Choice Questions......Page 431 Review Questions......Page 434 Appendix-A: Debugging Python Code......Page 436 Bibliography......Page 446 Solutions......Page 448 Index......Page 458

Similar books

Session C11: Ancient Cultural Landscapes in South Europe – their Ecological Setting and Evolution, Session C22: Gardeners from South America, Session S04: Agro-Pastoralism and Early Metallurgy Sessions, Session WS29: The Idea of Enclosure in Recent Iberian Prehistory, Session C88: Rhytmes et causalites des dynamiques de l'anthropisation en Europe entre 6500 ET 500 BC: Hypotheses socio-culturelles et/ou climatiques: Proceedings of the XV UISPP World Congress (Lisbon 4-9 September 2006) / Actes du XV Congrès Mondial (Lisbonne 4-9 Septembre 2006) Vol.36

Session C11: Ancient Cultural Landscapes in South Europe – their Ecological Setting and Evolution, Session C22: Gardeners from South America, Session S04: Agro-Pastoralism and Early Metallurgy Sessions, Session WS29: The Idea of Enclosure in Recent Iberian Prehistory, Session C88: Rhytmes et causalites des dynamiques de l'anthropisation en Europe entre 6500 ET 500 BC: Hypotheses socio-culturelles et/ou climatiques: Proceedings of the XV UISPP World Congress (Lisbon 4-9 September 2006) / Actes du XV Congrès Mondial (Lisbonne 4-9 Septembre 2006) Vol.36

2010 · PDF

THE BRITISH ARMY IN INDIA: ITS PRESERVATION BY AN APPROPRIATE CLOTHING, HOUSING, LOCATING, RECREATIVE EMPLOYMENT, AND HOPEFUL ENCOURAGEMENT OF THE TROOPS. with AN APPENDIX ON INDIA : THE CLIMATE OP ITS HILLS ; THE DEVELOPMENT OF ITS RESODRCBS, INDUSTRY, AND ARTS ; THE ADMINISTRATION OF JUSTICE ; THE BLACK ACT ; THE PROGRESS OF CHRISTIANITY ; THE TRAFFIC IN OPIUM ; THE VALUE OF INDIA ; PERMANENT CAUSES OF DISAFFECTION, AND OF THE RECENT REBELLION ; THE TRADITIONARY POLICY; MISGOVERNMENT BY NATIVE RULERS ; ANNEXATIONS OF THEIR TERRITORY, ETC.

THE BRITISH ARMY IN INDIA: ITS PRESERVATION BY AN APPROPRIATE CLOTHING, HOUSING, LOCATING, RECREATIVE EMPLOYMENT, AND HOPEFUL ENCOURAGEMENT OF THE TROOPS. with AN APPENDIX ON INDIA : THE CLIMATE OP ITS HILLS ; THE DEVELOPMENT OF ITS RESODRCBS, INDUSTRY, AND ARTS ; THE ADMINISTRATION OF JUSTICE ; THE BLACK ACT ; THE PROGRESS OF CHRISTIANITY ; THE TRAFFIC IN OPIUM ; THE VALUE OF INDIA ; PERMANENT CAUSES OF DISAFFECTION, AND OF THE RECENT REBELLION ; THE TRADITIONARY POLICY; MISGOVERNMENT BY NATIVE RULERS ; ANNEXATIONS OF THEIR TERRITORY, ETC.

1858 · PDF

Idries Shah 27 Books Collection : A Perfumed Scorpion, A Veiled Gazelle, Caravan of Dreams, Darkest England, Destination Mecca, Evenings with Idries Shah, Knowing How to Know, Learning How to Learn, Letters and Lectures of Idries Shah, Neglected aspects of Sufi study, Observations, Oriental Magic, Reflections, Seeker after Truth, Special Illumination, Special Problems in the study of Sufi ideas, Sufi thought and action, Tales of the Dervishes, The Dermis Probe, The Elephant in the Dark, The Englishman Handbook, Idries Shah Antology, The Magic Monastery, The natives are restless, wisdom of the Idiots PDF.

Idries Shah 27 Books Collection : A Perfumed Scorpion, A Veiled Gazelle, Caravan of Dreams, Darkest England, Destination Mecca, Evenings with Idries Shah, Knowing How to Know, Learning How to Learn, Letters and Lectures of Idries Shah, Neglected aspects of Sufi study, Observations, Oriental Magic, Reflections, Seeker after Truth, Special Illumination, Special Problems in the study of Sufi ideas, Sufi thought and action, Tales of the Dervishes, The Dermis Probe, The Elephant in the Dark, The Englishman Handbook, Idries Shah Antology, The Magic Monastery, The natives are restless, wisdom of the Idiots PDF.

2022 · PDF

The travels of Capts. Lewis and Clarke from St. Louis, by way of the Missouri and Columbia rivers, to the Pacific ocean; performed in the years 1804, 1805 & 1806, by order of the government of the United States. Containing delineations of the manners, customs, religion, &c. of the Indians, comp. from various authentic sources, and original documents, and a summary of the Statistical view of the Indian nations, from the official communication of Meriwether Lewis. Illustrated with a map of the country, inhabited by the western tribes of Indians

The travels of Capts. Lewis and Clarke from St. Louis, by way of the Missouri and Columbia rivers, to the Pacific ocean; performed in the years 1804, 1805 & 1806, by order of the government of the United States. Containing delineations of the manners, customs, religion, &c. of the Indians, comp. from various authentic sources, and original documents, and a summary of the Statistical view of the Indian nations, from the official communication of Meriwether Lewis. Illustrated with a map of the country, inhabited by the western tribes of Indians

1809 · PDF