N3887 Python Programming BCA Science Sem 6
N3887 Python Programming BCA Science Sem 6
Python Programming
For
B.C.A. Science : Semester - VI
Price ` 180.00
N3887
Python Programming ISBN 978-93-88706-83-4
First Edition : January 2019
© : Author
The text of this publication, or any part thereof, should not be reproduced or transmitted in any form or stored in any computer storage system or device for
distribution including photocopy, recording, taping or information retrieval system or reproduced on any disc, tape, perforated media or other information storage
device etc., without the written permission of Author with whom the rights are reserved. Breach of this condition is liable for legal action.
Every effort has been made to avoid errors or omissions in this publication. In spite of this, errors may have crept in. Any mistake, error or discrepancy so
noted and shall be brought to our notice shall be taken care of in the next edition. It is notified that neither the publisher nor the author or seller shall be
responsible for any damage or loss of action to any one, of any kind, in any manner, therefrom.
Published By : Printed By :
NIRALI PRAKASHAN STAR COPIERS PVT. LTD.
Abhyudaya Pragati, 1312, Shivaji Nagar Kumthekar Road, Sadashiv Peth
Off J.M. Road, PUNE – 411005 Pune - 411 030
Tel - (020) 25512336/37/39, Fax - (020) 25511379 Tel - (020) 24479201
Email : niralipune@pragationline.com
DISTRIBUTION CENTRES
PUNE
Nirali Prakashan : 119, Budhwar Peth, Jogeshwari Mandir Lane, Pune 411002, Maharashtra
(For orders within Pune) Tel : (020) 2445 2044, 66022708, Fax : (020) 2445 1538; Mobile : 9657703145
Email : niralilocal@pragationline.com
Nirali Prakashan : S. No. 28/27, Dhayari, Near Asian College Pune 411041
(For orders outside Pune) Tel : (020) 24690204 Fax : (020) 24690316; Mobile : 9657703143
Email : bookorder@pragationline.com
MUMBAI
Nirali Prakashan : 385, S.V.P. Road, Rasdhara Co-op. Hsg. Society Ltd.,
Girgaum, Mumbai 400004, Maharashtra; Mobile : 9320129587
Tel : (022) 2385 6339 / 2386 9976, Fax : (022) 2386 9976
Email : niralimumbai@pragationline.com
DISTRIBUTION BRANCHES
JALGAON
Nirali Prakashan : 34, V. V. Golani Market, Navi Peth, Jalgaon 425001, Maharashtra,
Tel : (0257) 222 0395, Mob : 94234 91860; Email : niralijalgaon@pragationline.com
KOLHAPUR
Nirali Prakashan : New Mahadvar Road, Kedar Plaza, 1st Floor Opp. IDBI Bank, Kolhapur 416 012
Maharashtra. Mob : 9850046155; Email : niralikolhapur@pragationline.com
NAGPUR
Nirali Prakashan : Above Maratha Mandir, Shop No. 3, First Floor,
Rani Jhanshi Square, Sitabuldi, Nagpur 440012, Maharashtra
Tel : (0712) 254 7129; Email : niralinagpur@pragationline.com
DELHI
Nirali Prakashan : 4593/15, Basement, Agarwal Lane, Ansari Road, Daryaganj
Near Times of India Building, New Delhi 110002 Mob : 08505972553
Email : niralidelhi@pragationline.com
BENGALURU
Nirali Prakashan : Maitri Ground Floor, Jaya Apartments, No. 99, 6th Cross, 6th Main,
Malleswaram, Bengaluru 560003, Karnataka; Mob : 9449043034
Email: niralibangalore@pragationline.com
Other Branches : Hyderabad, Chennai
Note : Every possible effort has been made to avoid errors or omissions in this book. In spite this, errors may have crept in. Any type of error or mistake so noted,
and shall be brought to our notice, shall be taken care of in the next edition. It is notified that neither the publisher, nor the author or book seller shall be responsible
for any damage or loss of action to any one of any kind, in any manner, therefrom. The reader must cross check all the facts and contents with original Government
notification or publications.
niralipune@pragationline.com | www.pragationline.com
1.1 INTRODUCTION
• Python Programming Language is a high-level and interpreted programming language which was
created by Guido Van Rossum in 1989. It was first released in 1991, which results in a great general
purpose language capable of creating anything from desktop software to web applications and
frameworks.
• There are two major Python versions: Python 2 and Python 3. Both are quite different.
• Python scripts normally have the extension .py, but this is not required. You can execute the script by
the command: python hw.py
• This command specifies explicitly that a program python is to be used to interpret the contents of the
hw.py file.
• For the python hw.py … command and to work, you need to be in a console window, also known as a
Terminal Window on Unix, and as a command prompt or MS-DOS prompt on Windows. The Windows
habit of double-clicking on the file icon does not work for scripts requiring command-line
information, unless you have installed PythonWin.
1.1
Python Programming (BCA Science: VI) Introduction to Python Scripting
1.2
1.2
Python Programming (BCA Science: VI) Introduction to Python Scripting
• Scripting Languages: A Scripting Language is a programming language designed for integrating and
communicating with other programming languages. These are generally extremely high-level and
powerful.
Example:
Example: JavaScript, VBScript, PHP, Perl, Python, Ruby, ASP and Tcl.
• Domain--specific Languages
Domain Languages:: A Domain-specific Language (DSL) is a programming language that is
developed to meet a specific need. These are used in highly special-purpose areas only.
Example:
Example: Cascading Style Sheets (CSS), Ant and SQL.
• Visual Languages:
Languages: Visual Programming Languages (VPL) allows users specify programs in a two-(or
more)-dimensional way, instead of as one-dimensional text strings, via graphic layouts of various
types .
Example:
Example: Analytica, Blockly, Toontalk.
• languages: An Esoteric Programming Language is a programming language designed as a test
Esoteric languages
of the boundaries of computer programming language design, as a proof of concept, or as a joke.
These are not really intended to be used, but are very interesting, funny, or educational in some way.
Example:
Example: Beatnik, Befunge, Piet, whitespace
• Language:: Glue language refers to a Programming Language that is designed specifically to
Glue Language
write and manage program and code, which connects together different software components. Glue
language primarily enables creating glue code. It enables interconnecting, support and the
integration of software programs and components created using different programming languages
and platforms. The Glue code written in glue language doesn’t provide any functional value to the
core software, but enables connecting the processes and features of multiple smaller and directly
incompatible components. The gluing of these components provides enhanced features and
functionality to the base software/solution.
Glue Language is very useful in rapid prototyping environments where multiple software utilities are
glued together quickly before being developed in a single programming language or framework.
Example: VBScript, Ruby, Python, Perl and PHP.
• Differences between Programming Vs Scripting:
Scripting:
1. Programming languages do not require a host; these are executable whereas Scripting languages
need a host.
2. Programming languages are complex and tedious to learn whereas Scripting languages are easier
to learn, write and master as compared to Programming languages.
3. Programming languages are generally compiled and create an executable file whereas Scripting
languages are interpreted and do not create an executable file.
4. Programming language code is compiled and byte code are converted into machine code in one
shot whereas, in Scripting, high-level instructions are converted into machine language
straightaway.
5. Programming languages are most often used to build something from scratch whereas Scripting
languages can be used to combined existing component or module.
6. Programming languages are designed in such a way a developer can take full advantage of
features of a language whereas Scripting languages are designed to make coding faster and
simpler.
7. With programming language, numerous lines of code are needed for each function whereas
Scripting languages require lesser lines of code to write functions.
8. Programming languages increased maintenance cost whereas with Scripting, maintenance cost is
drastically reduced.
9. C, C++, C#, Java, VC++, COBOL, Pascal etc., are examples of Programming languages whereas
JavaScript, VB Script, Python, Ruby etc., are examples of Scripting languages.
1.4
1.4
Python Programming (BCA Science: VI) Introduction to Python Scripting
1.6
1.6