CONTENTS
Unit 1: Introduction, Variables, and Data Types 1–19
1.1 History 33355
1.2 Features 9 12 15
1.3 Installation and Execution 20–48
1.4 Hello World!
1.5 Input and Output 22
1.6 Basic Data Types and Operators 31
1.7 Strings 49–79
1.8 Compound Data Types
51
Unit 2: Control Structures
64
2.1 Conditionals 71
2.2 Loops
80–118
Unit 3: Functions, Modules, and Packages 81
3.1 Functions 96
3.2 Modules 104
3.3 Packages 110
Unit 4: Files and Regular Expressions 119–138
4.1 File Input/Output 120
4.2 Text Processing
4.3 Pattern Matching and Regular Expressions 122
4.4 Application: Querying Publication Data 130
139 141-
Unit 5: Django Framework 143
5.1 Installing and Running Django
5.2 Creating and Running a Web Application
5.3 Parameter Passingwith GET
References for Further Learning
Index
Introduction, Variables,
d
1 and Data Types
UNIT SPECIFICS
Throughthisunit we discuss the following aspects:
● History of the Python Programming Language
● Overall set of features supported by Python
● Basic setup and installation
● Basic data types, operators, input and output
RATIONALE
This introductory unit gets readers acquainted with the basics of Python programming. It starts
with a brief history of Python’s creation. The unit then lists the language’s overall set of features
at a high level and motivates why it has become so popular. The unit then delves into basic
language syntax, variables, and solves a few known problems in Python. We then introduce
various data types such as numbers and strings and solve problems using those. We end this unit
by introducing aggregate data types such as lists, tuples, and dictionaries. Care has been taken to
introduce the readers to interesting problems despite the limitation of not having a conditional
statement or a loop.
PRE-REQUISITES None