270
pages
English
Ebooks
2020
Vous pourrez modifier la taille du texte de cet ouvrage
Obtenez un accès à la bibliothèque pour le consulter en ligne En savoir plus
Découvre YouScribe en t'inscrivant gratuitement
Découvre YouScribe en t'inscrivant gratuitement
270
pages
English
Ebook
2020
Vous pourrez modifier la taille du texte de cet ouvrage
Obtenez un accès à la bibliothèque pour le consulter en ligne En savoir plus
Publié par
Date de parution
11 février 2020
Nombre de lectures
0
EAN13
9789389845037
Langue
English
Publié par
Date de parution
11 février 2020
Nombre de lectures
0
EAN13
9789389845037
Langue
English
Let Us Python
Second Edition
Yashavant Kanetkar Aditya Kanetkar
FIRST EDITION 2019
Revised and Updated Edition 2020
Copyright © BPB Publications, INDIA
ISBN: 978-93-89845-00-6
All Rights Reserved. No part of this publication can be stored in a retrieval system or reproduced in any form or by any means without the prior written permission of the publishers.
LIMITS OF LIABILITY AND DISCLAIMER OF WARRANTY
The Author and Publisher of this book have tried their best to ensure that the programmes, procedures and functions described in the book are correct. However, the author and the publishers make no warranty of any kind, expressed or implied, with regard to these programmes or the documentation contained in the book. The author and publisher shall not be liable in any event of any damages, incidental or consequential, in connection with, or arising out of the furnishing, performance or use of these programmes, procedures and functions. Product name mentioned are used for identification purposes only and may be trademarks of their respective companies.
All trademarks referred to in the book are acknowledged as properties of their respective owners.
Distributors:
BPB PUBLICATIONS
20, Ansari Road, Darya Ganj
New Delhi-110002
Ph: 23254990/23254991
BPB BOOK CENTRE
376 Old Lajpat Rai Market,
Delhi-110006
Ph: 23861747
MICRO MEDIA
Shop No. 5, Mahendra Chambers,
150 DN Rd. Next to Capital Cinema,
V.T. (C.S.T.) Station, MUMBAI-400 001
Ph: 22078296/22078297
DECCAN AGENCIES
4-3-329, Bank Street,
Hyderabad-500195
Ph: 24756967/24756400
Published by Manish Jain for BPB Publications, 20, Ansari Road, Darya Ganj, New Delhi-110002 and Printed by Repro India Pvt Ltd, Mumbai
Dedicated to
Nalinee & Prabhakar Kanetkar…
About the Authors
Yashavant Kanetkar
Through his books and Quest Video Courses on C, C++, Java, Python, Data Structures, .NET, IoT, etc. Yashavant Kanetkar has created, molded and groomed lacs of IT careers in the last three decades. Yashavant's books and Quest videos have made a significant contribution in creating top-notch IT manpower in India and abroad.
Yashavant's books are globally recognized and millions of students / professionals have benefitted from them. Yashavant's books have been translated into Hindi, Gujarati, Japanese, Korean and Chinese languages. Many of his books are published in India, USA, Japan, Singapore, Korea and China.
Yashavant is a much sought after speaker in the IT field and has conducted seminars/workshops at TedEx, IITs, IIITs, NITs and global software companies.
Yashavant has been honored with the prestigious “Distinguished Alumnus Award” by IIT Kanpur for his entrepreneurial, professional and academic excellence. This award was given to top 50 alumni of IIT Kanpur who have made significant contribution towards their profession and betterment of society in the last 50 years.
In recognition of his immense contribution to IT education in India, he has been awarded the “Best .NET Technical Contributor” and “Most Valuable Professional” awards by Microsoft for 5 successive years.
Yashavant holds a BE from VJTI Mumbai and M.Tech. from IIT Kanpur. Yashavant's current affiliations include being a Director of KICIT Pvt. Ltd. and KSET Pvt. Ltd. He can be reached at kanetkar@kicit.com or through http://www.kicit.com.
Aditya Kanetkar
Aditya Kanetkar is currently working as a backend Software Engineer at Microsoft, Redmond, USA. He has been designing distributed systems software for the last 4 years. He has worked at multiple companies in the past, including Oracle, Redfin, Amazon and Arista Networks.
Aditya holds a Master's degree in Computer Science from Georgia Tech, Atlanta, and a Bachelor's degree in Computer Science and Engineering from IIT Guwahati. His current passion is anything remotely connected to Python, Machine Learning, Distributed Systems, Cloud Computing and C# related technologies. Aditya can be reached at aditya@kicit.com or through http://www.kicit.com.
Preface To Second Edition
Programming landscape has changed significantly over the last few years. Python is making inroads into every field that has anything to do with programming. Naturally, Python programming is a skill that one has to acquire, earlier the better.
If you have no programming background and you are learning Python as your first programming language you will find the book very simple to understand. Primary credit of this goes to the Python language—it is very simple for the beginner, yet very powerful for the expert who can tap into its power.
If you have some acquaintance with a programming language, you need to get off the ground quickly. To do that you need to understand the similarities/differences in a feature that you have used in other language(s) and new features that Python offers. In both respects this book should help you immensely. Instead of explaining a feature with verbose text, we have mentioned the key points about it as ‘KanNotes’ and explained those points with the help of programs.
The most important characteristic of this book is its simplicity—be it the code or the text. You will also notice that very few programming examples in this book are code fragments. We have realized that a program that actually compiles and runs, helps improve one's understanding of a subject a great deal more, than just code snippets.
Exercises are exceptionally useful to complete the reader's understanding of a topic. So you will find one at the end of each chapter. Please do attempt them. They will really make you battle-ready. If you want solutions to these exercises then take a look at our book ‘Let Us Python Solutions’ that we are stitching together right now.
The immense success of first edition of ‘Let Us Python’ has enthused us to pour our best efforts creating this second edition. Admittedly, in the first edition there were a few key places where the topic change was a bit jarring. To address this issue many chapters have been reorganized, split or combined. In addition many new chapters have been added in this edition.
We have tried to write a Python book that makes reading it as much fun as the language is. Enjoy the book and your journey into the Python world!
Brief Contents
1 Introduction to Python
2 Python Basics
3 Strings
4 Decision Control Instruction
5 Repetition Control Instruction
6 Console Input/Output
7 Lists
8 Tuples
9 Sets
10 Dictionaries
11 Comprehensions
12 Functions
13 Recursion
14 Functional Programming
15 Modules and Packages
16 Namespaces
17 Classes and Objects
18 Intricacies of Classes and Objects
19 Containership and Inheritance
20 Iterators and Generators
21 Exception Handling
22 File Input/Output
23 Miscellany
24 Multi-threading
25 Synchronization
Index
Table of Content
1 Introduction to Python
What is Python?
Reasons for Popularity
What sets Python apart?
What can be done using Python?
Who uses Python today?
Python Resources
Programming Paradigms
Functional Programming Model
Procedural Programming Model
Object-oriented Programming Model
Event-driven Programming Model
Exercise
2 Python Basics
Python Specification
Working with Python
Identifiers and Keywords
Python Types
Integer and Float Ranges
Variable Type and Assignment
Arithmetic Operators
Operation Nuances
Operator Precedence
Conversions
Built-in Functions
Library Functions
Python Type Jargon
Comments and Indentation
Multi-lining
Programs
Exercise
3 Strings
What are Strings?
Accessing String Elements
String Properties
String Operations
Programs
Exercise
4 Decision Control Instruction
Decision Control Instruction
Logical Operators
Conditional Expressions
Programs
Exercise
5 Repetition Control Instruction
Repetition Control Instruction
Usage of while and for
break and continue
pass Statement
Programs
Exercise
6 Console Input/Output
Console Input
Console Output
Formatted Printing
Programs
Exercise
7 Lists
What are Lists?
Accessing List Elements
Basic List Operations
List Methods
List Varieties
Programs
Exercise
8 Tuples
What are Tuples?
More Ways to Create Tuples
Accessing Tuple Elements
Tuple Operations
Tuple Varieties
Programs
Exercise
9 Sets
What are Sets?
Accessing Set Elements
Set Operations
Set Methods
Mathematical Set Operations
Updating Set Operations
Programs
Exercise
10 Dictionaries
What are Dictionaries?
Accessing Dictionary Elements
Dictionary Operations
Dictionary Methods
Nested Dictionary
Programs
Exercise
11 Comprehensions
What are Comprehensions?
List Comprehension
Set Comprehension
Dictionary Comprehension
Programs
Exercise
12 Functions
What are Functions?
Communication with Functions
Types of Arguments
Unpacking Arguments
Programs
Exercise
13 Recursion
Recursive Functions
Recursive Factorial Function
Types of Recursion
Recursion Limit
Programs
Exercise
14 Functional Programming
Functional Programming
Functions as First-class Values
Lambda Functions
Higher Order Functions
Map, Filter, Reduce
map() Function
filter() Function
reduce() Function
Using Lambda with map() , filter() , reduce()
Where are they Useful?
Programs
Exercise
15 Modules and Packages
The Main Module
Multiple Modules
Importing a Module
Variations of import
Search Sequence
Same Code, Different Interpretation
Packages
Third-party Packages
Programs
Exercise
16 Namespaces
Symbol Table
Namespace
globals() and locals()
Where to use them?
Inner Functions
Scope and LEGB Rule
Programs
Exercise
17 Classes and Objects
Programming Paradigms
What are Classes and Objects?
Public and Private Members
Class Declaration and Object Creation
Object Initialization
Class Variables and Methods
vars() and dir() Functions
vars() and dir() with Classes and Objects