Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
Cover Page
Title Page
Copyright Page
Dedication Page
About the Author
About the Reviewer
Acknowledgement
Preface
Errata
Table of Contents
1. Introduction
Introduction
Structure
Objectives
1.1 Overview of programming languages
1.1.1 High-level programming languages
1.1.2 Low-level programming languages
1.1.2.1 Machine language
1.1.2.2 Assembly language
1.2 Language processors
1.2.1 Assembler
1.2.2 Compiler
1.2.3 Interpreter
1.3 Generations of programming languages
1.4 Programming paradigms
1.5 History of Python
1.6 Features of Python
1.7 Future of Python
1.8 Installing Python in 5 simple steps
1.9 Memory management in Python
1.10 Python versus Java
Points to remember
Conclusion
Multiple choice questions
Answers
Short questions and answers
Descriptive questions and answers
2. Python Basics
Introduction
Structure
Objectives
2.1 Integrated Development and Learning Environment
Editor
2.2 Tokens
2.2.1 Python reserved words/keywords
2.2.2 Python identifiers
2.2.2.1 Python Variables
2.2.3 Python literals
2.2.4 Delimiter
2.2.5 Python operators
2.3 Python comments
2.3.1 Comments - When writing code for yourself
2.3.2 Comments help others read your code
2.3.3 How to write comments
2.3.4 Python docstring and comment
2.4 Indentation
2.5 Constants
2.6 Static and dynamic typing
2.7 Data types
2.8 Statements in Python
Points to remember
Conclusion
Multiple choice questions
Answers
Short questions and answers
Descriptive questions and answers
3. Numbers, Operators and In-built Functions
Introduction
Structure
Objectives
3.1 Numbers in Python
3.2 Boolean variables and expressions
3.2.1 Conversion of boolean to integer and vice versa
3.3 Operators
3.3.1 Arithmetic operators
3.3.1.1 Arithmetic operators precedence in Python
3.3.2 Relational/Comparison/Conditional operator
3.3.3 Logical operator (Boolean expressions)
3.3.2.1 The ‘and’ operator
3.3.2.2 The ‘or’ operator
3.3.2.3 The ‘not’ operator
3.3.4 The ‘Assignment’ operator
3.3.5 Bitwise operators
3.3.5.1 Binary AND
3.3.5.2 Binary OR
3.3.5.3 Binary XOR
3.3.5.4 Binary ones complement
3.3.5.5 Binary left shift
3.3.5.6 Binary right shift
3.3.6 Membership operators
3.3.7 Identity operators
3.2.8 Operator precedence and associativity
3.4 Built-in functions for math operators
3.4.1 Functions available for conversion of numbers from one type to another
3.5 Math module
3.5.1 Mathematical functions
3.5.2 Trigonometric functions
3.6 Working with random numbers
3.7 Float representation and equality
3.8 Statements
3.8.1 Simple statements
3.8.2 Compound statements
3.9 Date/Time module
Points to remember
Conclusion
Multiple choice questions
Answers
Short questions and answers
Coding questions and answers
Descriptive questions and answers
4. Strings
Introduction
Structure
Objective
4.1 Introduction to strings
4.2 Escape characters
4.2.1 Using quotes inside quotes
4.3 Getting the user input and displaying output
4.3.1 input() function
4.3.2 Possibilities of printing output
4.4 Typecasting data types
4.5 String indexing and string length
4.5.1 String Index
4.5.2 Length of a string
4.6 Basic string operations
4.6.1 Concatenation of Strings
4.6.2 Repetition
4.6.3 Strings are immutable
4.6.4 String slicing and how it is different from indexing
4.7 Strings in-built or predefined methods
4.7.1 help()
4.7.2 find()
4.7.3 upper()
4.7.4 lower()
4.7.5 strip()
4.7.6 replace()
4.7.7 split()
4.7.8 join()
4.7.9 in and not in
4.7.10 endswith()
4.7.11 Some fun with string methods
4.7.11.1 capitalize()
4.7.11.2 casefold()
4.7.11.3 centre()
4.7.11.4 count()
4.7.11.5 encode()
4.7.11.6 endswith()
4.7.11.7 find()
4.7.11.8 format()
4.7.11.9 index()
4.7.11.10 isalnum()
4.7.11.11 isalpha()
4.7.11.12 isdecimal()
4.7.11.13 isdigit()
4.7.11.14 islower()
4.7.11.15 isnumeric()
4.7.11.16 isspace()
4.7.11.17 lower()
4.7.11.18 swapcase()
4.8 Regular expression
4.8.1 Working with ordinary characters
4.8.2 Wild card characters: Special characters
4.8.2.1 A period(.)
4.8.2.2 Caret(^)
4.8.2.3 End of String($)
4.8.2.4 Match any single character ([….])
4.8.2.5 Backslash(\)
4.8.2.5 \w - Lowercase 'w'
4.8.2.6 \W - Uppercase 'W'. Matches any character not part of \w
4.8.2.7\s matches whitespace equivalent to [\t,\n,\r,\f]
4.8.2.8 \d matches digits
4.8.2.9 \D matches non-digits
4.8.2.10 \A matches beginning of a string
4.8.2.11 \Z same as ‘$’
4.8.2.12 \b matches only the beginning of a word
4.8.3 Repetitions
4.8.3.1 +
4.8.3.2 *
4.8.3.3{}
4.8.3.4 ?
4.8.4 Grouping
4.8.5 Functions provided by re module
4.8.5.1 compile()
4.8.5.2 search()
4.8.5.3 match()
4.8.5.4 findall()
4.8.5.5 finditer()
4.8.5.6 sub()
4.8.5.7 split()
4.8.6 Compilation flags
Points to remember
Conclusion
Multiple choice questions
Answer
Short questions and answers
Coding questions and answers
Descriptive questions and answers
5. Lists and Arrays
Introduction
Structure
Objective
5.1 What is a list?
5.1.1 Nested lists
5.2 List operations, functions and methods
5.2.1 List operations
5.2.1.1 Concatenation of lists
5.2.1.2 Repetition
5.2.1.3 Slicing of a list
5.2.1.4 Membership
5.2.1.5 del()
5.2.2 In-built list methods
5.2.2.1 append()
5.2.2.2 extend()
5.2.2.3 insert()
5.2.2.4 sort()
5.2.2.5 pop()
5.2.2.6 remove()
5.2.2.7 reverse()
5.2.3 In-built functions
5.2.3.1 all()
5.2.3.2 any ()
5.2.3.3 len ()
5.2.3.4 count()
5.2.3.5 index()
5.2.3.6 max()
5.2.3.7 min ()
5.2.3.8 sum()
5.2.3.9 sorted()
5.2.3.10 list()
5.2.3.11 join()
5.3 Aliasing and cloning
5.3.1 Cloning of lists
5.4 List comprehensions
5.5 Arrays
5.5.1 Properties of arrays:
5.5.2 Accessing Python arrays
5.5.3 Changing elements of an array
5.5.4 Appending values to an array
5.5.5 Removing Python array elements
5.5.5.1 Using del
5.5.5.2 Using remove()
Points to remember
Conclusion
Multiple choice questions
Answer
Short questions and answers
Coding questions and answers
Descriptive questions and answers
6. Tuples and Dictionaries
Introduction
Structure
Objective
6.1 Introducing tuples
6.1.1 Creating a tuple
6.1.2 Accessing elements of a tuple
6.1.2.1 Using index value
6.1.2.2 Using slice operation
6.1.3 Tuple operations and in-built methods
6.1.3.1 ‘+’ Operator
6.1.3.2 count()
6.1.3.3 index()
6.1.3.4 in/ not in
6.1.3.5 len()
6.1.3.6 * Operator
6.1.3.7 max()
6.1.3.8 sorted()
6.1.4 Tuples vs lists
6.2 Introducing dictionaries
6.2.1 Features of a dictionary
6.2.2 Creating a dictionary object
6.2.3 Accessing values of a dictionary
6.2.4 Dictionary in-built methods
6.2.4.1 Deleting or removing elements from a dictionary
6.2.4.1.1 pop()
6.2.4.1.2 popitem()
6.2.4.1.3 del
6.2.4.2 clear()
6.2.4.3 copy()
6.2.4.4 fromkeys()
6.2.4.5 items()
Points to remember
Conclusion
Short questions and answers
Coding questions and answers
Descriptive questions and answers
7. Sets and Frozen Sets
Introduction
Structure
Objective
7.1 Sets
7.2 Sets’ basic rules
7.3 Conversions with sets
7.4 Working with sets
7.4.1 Operator: in/not in, ==, <, <=, >, >=
7.4.1.1 in and not in
7.4.1.2 == Operator
7.4.1.3 < Operator
7.4.1.4 <= Operator
7.4.1.5 > Operator
7.4.2 Set methods: add(), clear(), and copy()
7.4.2.1 add()
7.4.2.2 clear()
7.4.2.3 copy()
7.4.2.4 discard() and remove()
7.4.2.5 pop()
7.4.2.6 update()
7.5 Set operations
7.5.1 Difference (-)
7.5.2 Symmetric difference (^)
7.5.3 Union(|)
7.5.4 Intersection(&)
7.5.5 isdisjoint()
7.6 Frozen sets
7.7 Difference between sets and frozen sets
Points to remember
Conclusion
Short questions and answers
Coding questions and answers
Descriptive questions and answers
8. Program Flow Control in Python
Introduction
Structure
Objective
8.1 Working with ‘if’
8.1.1 If .. elif..else
8.1.2 ’if’ statement
8.1.3 ’if…else’ statement
8.1.4 Nested if statement
8.2 ‘for’ loops
8.2.1 Iterating over a range of numbers
8.2.1.1 Convert a range into a list
8.2.1.2 Negative steps in range
8.3 ‘while’ loops
8.4 ’else’ clause with loops
8.5 continue, break, and pass statements
8.6 Recap on control structures
8.7 Python iterators
8.8 Python generators
Points to remember
Conclusion
Multiple choice questions
Answer
Coding questions and answers
Descriptive questions and answers
Index
← Prev
Back
Next →
← Prev
Back
Next →