Core Python 3.8 Programming
Rajan Chattamvelli
Amazon
Contents
CORE PYTHON 3.8 PROGRAMMING
Rajan Chattamvelli
Preface
This book grew out of a course on Python programming that I taught to computer science majors. It is intended for beginning students in Python programming courses who already have some exposure to programming (all of my students had done C programming). No prerequisites are needed except familiarity with an IDE or editor. First-time learners will find enough information on the basics in the first chapter.
Why a New Book?
Although there are many excellent books on Python programming written by several experts with different perspectives, most of them are either narrowly focused, less informative than online documentations, or too advanced. Some of the books even spend several chapters on less important things like background and history, installation and setup, getting started with Python prompt etc. This information is already available at dozens of sites on the web, which anyone with a net connection can look-up. A clear advantage of this book over others in the market is that it explores several concepts in-depth that are not to be found elsewhere, including online documentations. This new-found knowledge will help the readers to apply it with advantage in solving several practical problems with ease.
The book helps beginners to grasp the topics faster than using other textbooks in the market. Several concepts are explained thoroughly and practical examples are used wherever possible to instill a genuine interest in the reader to learn Python and apply what they have learned in practical situations. Examples are drawn from a wide variety of fields. This will benefit a large number of students in various fields of study. Some topics have been presented in an intuitive way different from most of the available online materials or in books. Readers will appreciate this classroom tested book for its clarity, comprehensive coverage, and the correct balance between theory and applications.
Audience
The primary users of this book are undergraduate students in computer science (first- or second semester introductory computer science (CS1) course). Typical courses include Introduction to Programming with Python, Introduction to computer science using Python, Python Programming etc. Students in engineering and mathematical sciences, business and management, and researchers in various fields who need to grasp a new programming language quickly will also find this book to be immensely useful. The secondary users include self-study professionals, and Python certification aspirants. It is also useful for self-learners and programmers experienced in other languages who need to quickly learn Python language. This book will make those developers who have experience with at least one higher level programming language exposure up to speed with the language in a very short time. The tangible reader benefits are as follows: 1) Students could definitely get a much better grasp of the nitty-gritty details of the fundamentals of Python programming through this book than through most other books in the market. 2)
Researchers get hands-on experience in applying the core ideas through the illustrative examples given throughout. 3) Software developers can equip themselves with practical ways to solve problems. 4) Scientists will find the insightful results and programs to be of compelling value in practical applications. 5) Teachers will be able to deepen their understanding of core Python concepts 6) Certification aspirants will find the book to be of immense value due to the right amount of theory and practical examples mixed together.
This book can be used for class-room teaching of undergraduate level courses in Python programming , Introduction to computer science using Python etc. Some of the chapters can also be used as supplementary reading for courses on fundamentals of programming.
What it covers
This book covers the core Python. The first chapter briefly reviews the history of Python, salient features, and its availability on various platforms. Installation instructions are briefly mentioned, followed by interpretation and running of Python programs by transforming source code into bytecode. Python interactive console is discussed next, followed by source file naming. The Python comments are next explored and code snippets given to illustrate its use. A discussion of docstring and their uses can be found in chapter 1. This is followed by reserved words, constants, identifier naming, Input and Output statements, assignment statements and priority of operators. The end-of-chapter exercises selected from a variety of fields help the students to write simple program statements which can be tried at the Python prompt or from source files. Chapter 2 discusses data types and conversions between types. A discussion on standard data types (Boolean, integer, long, float, complex and compound types), date and time data types. Chapter 3 on Python operators gives an in-depth insight into various operators including arithmetic, assignment, relational, chained relational, logical and bit-wise operators and shorthand operators like += etc. The chapter ends with a discussion of operator overloading.
Decisions (If statements) are discussed in chapter 4. Topics covered include simple if statement, if with else and elif branches, compound conditions, short-circuit evaluations, nested if, trailing if statements etc.
Chapter 5 is about for loops, while loops, nested loops, range function, enumerated loops, and zip command in loops.
Chapter 6 on strings discusses creating strings, string prefixes, accessing characters, string slicing, string functions, formatting, and command line argument processing.
Common file operations, file creation, and special type of files like CSV-files, directory operations and formatted files are discussed in Chapter 7.
Chapter 8 is on functions. It describes function creation, invocation, default arguments, built-in functions, recursive functions, positional and keyword arguments, variable number of parameters, generator functions, inner functions and lambda functions.
Any queries or suggestions should be sent to dmmbook@gmail.com and will be acknowledged.
Rajan Chattamvelli
February 2020
List of Figures
1.1Available Installation Files...............................1-2
1.2Save Installation File..................................1-4
List of Tables
1.1Interpreted vs Compiled Languages................................1-9
1.2Popular Python Virtual Machines................................. 1-10
1.3Python Reserved words.......................................... 1-23
1.4Priority of Python Operators.......................................1-31
1.5Escape Sequences................................................. 1-32
2.1Language Type Categories...........................................2-2
2.2The Integer Family...................................................2-3
2.3Mutable vs Immutable Types in Python............................ 2-6
3.1Standard Arithmetic Operators..................................... 3-2
3.2Common Shorthand Operators.................................... 3-5
3.3Membership and Relational Operators............................. 3-9
3.4Logical Operators................................................ 3-11
3.5Logical AND and OR Table................................. 3-11