Book - Making Use of Python 09-07-2017, 02:37 PM
#1
![[Image: f8e8910ebb.png]](https://puu.sh/wZOfr/f8e8910ebb.png)
Code:
Scenario xxiii
Chapter 1 An Introduction to Python 1
Getting Started 1
Understanding Requirements 2
Determine Requirements of the University 2
Obtain Python and Its Documentation 3
Determine the System Requirements 4
Install Python 5
Start Python in Different Execution Modes 7
Summary 12
Chapter 2 Getting Started with Python 13
Getting Started 14
Writing Your First Python Program 14
Comments 15
Python as a Calculator 16
Using Variables in Python 16
Variables 17
Assigning Values to Variables 18
Standard Types 19
Identifiers and Keywords 39
Memory Management 40
Create a Sequence to Store All the Names of the Students 42
Write the Code to Display the Names of the Students 42
Contents
v
Declare a Dictionary of Student Purchases with the
Names of the Students as the Key 43
Write the Code to Display the Student Purchases 43
Save and Execute the Code 43
Verify the Details 44
Summary 44
Chapter 3 Intrinsic Operations and Input/Output 47
Getting Started 48
Using Input/Output Features and Intrinsic Operations
for Data Types in Python 48
Identify the Variables to Be Used 49
Accepting User Input 49
Formatting the Output 50
Introduction to Intrinsic Operations 55
Intrinsic Operations for Numeric Data Types 57
Intrinsic Operations for Strings 60
Intrinsic Operations for Lists and Tuples 66
Write the Code 71
Execute the Code 71
Summary 73
Chapter 4 Programming Basics 75
Getting Started 76
Conditional Operators 76
Order of Precedence of Operators 82
Using Programming Constructs 83
Identify the Control and Loop Statements to Be Used 84
Write the Code 94
Execute the Code 95
Summary 97
Chapter 5 Functions 99
Getting Started 100
Using Functions 100
Functions 101
Scope of Variables 118
Identify the Functions to Be Used 119
Write the Code 119
Execute the Code 121
Summary 122
Chapter 6 Modules 123
Getting Started 124
Using Modules 124
Modules 124
Packages 135
Identify the Modules to Be Used 136
vi Contents
Write the Code 137
Execute the Code 139
Summary 140
Chapter 7 Files 141
Getting Started 141
Using File Objects 142
Identify the Functions and Methods to Be Used 142
Write the Code to Store Course Details to the File 154
Execute the Code 155
Verify the Solution 155
Summary 156
Chapter 8 Object-Oriented Programming 157
Getting Started 158
Introducing OOP 158
Components of OOP 159
Benefits of OOP 160
Using Classes 161
Identify the Classes to Be Defined 162
Identifying the Class Objects 163
Identifying the Classes to Be Inherited and Their Objects 170
Identify the Methods to Be Overridden 173
Write the Code 182
Execute the Code 189
Summary 190
Chapter 9 Exception Handling 193
Getting Started 193
Handling Exceptions 194
Identify the Type of Error and Where the Error Occurs 196
Identify the Mechanism of Trapping the Exception 200
Identify the Location for the Code for Handling
the Exception to Be Written 209
Write the Code for Handling the Exception 209
Save and Execute the Code 210
Summary 210
Chapter 10 CGI Programming 213
Getting Started 213
Internet Basics 214
World Wide Web 217
Web Browsers 217
Hypertext Transfer Protocol (HTTP) 220
Revising HTML 221
Client-Side versus Server-Side Scripting 227
An Introduction to CGI 229
Contents vii
Writing CGI Applications 231
Write the Code for the HTML Form to Accept Data
from the User 231
Write the CGI Program in Python to Generate the
Results Page 232
Write the CGI Program to Generate Both the Form and
Results Pages 236
Execute the Code 237
Summary 239
Chapter 11 Database Programming 241
Getting Started 241
Database Management 242
Introduction to MySQL 243
Working with MySQL 246
Accessing a Database from a Python Script 254
Identify the Elements of the Table That Stores
Registration Details 256
Identify the Steps for Connecting to the Database 256
Write the Code to Create a Table in the Database 259
Write the Code to Insert the Registration Details
into the Table Created 260
Execute the Code to Create the Table in the Database 261
Execute the Code to Insert Data into the Table 261
Verify the Data in the Database 263
Summary 264
Chapter 12 Network Programming 267
Getting Started 267
Client/Server Architecture 268
Network Programming 269
Using Sockets 272
Identify the Sockets to Be Used 272
Write the Code to Run on the IT Department Computer 287
Write the Code to Run on the Admission Office Computer 288
Execute the Code Created for the IT Department Computer 289
Execute the Code Created for the Admission
Office Computer 290
Verify that Data Has Been Saved to a File in the
IT Department Computer 292
Summary 292
Chapter 13 Multithreaded Programming 297
Getting Started 297
Single-Threaded Applications 298
Threading in Python 299
viii Contents
Creating Multithreaded Applications 300
Identify the Class and the Methods to Create
a Multithreaded Application 300
Write Code for the Server 308
Write the Code for the Client 309
Execute the Code Created for the Server 310
Execute the Code Created for the Client 311
Summary 313
Chapter 14 Advanced Web Programming 315
Getting Started 316
Creating Web Servers 316
Accessing URLs 323
Creating Advanced CGI Applications 328
Identify the Elements of the Web Page for Entering
Assignment Details and Uploading the File 328
Identify the Methodology for Uploading the File 329
Identify the Methodology for Storing User Information 330
Write the Code for the CGI Script 335
Execute the CGI Script 339
Summary 340
Chapter 15 GUI Programming with Tkinter 343
Getting Started 343
Introduction to Tkinter 344
Creating a GUI Application 347
Identify the Components of the User Interface 348
Identify the Tkinter Widgets to Design the User Interface 348
Write the Code for the User Interface 360
Execute the Code 362
Summary 364
Appendix A Distributing COM Objects 365
Basics of COM 365
The Binary Standard 367
COM Interfaces 369
Binding 370
Python and COM 371
Creating COM Clients 371
Creating COM Servers 373![[Image: Vs4P58c.png]](https://i.imgur.com/Vs4P58c.png)




![[+]](https://sinister.ly/images/modern/collapse_collapsed.png)