Programming in Python
eBook - ePub

Programming in Python

Learn the Powerful Object-Oriented Programming

Dr. Pooja Sharma

Share book
  1. English
  2. ePUB (mobile friendly)
  3. Available on iOS & Android
eBook - ePub

Programming in Python

Learn the Powerful Object-Oriented Programming

Dr. Pooja Sharma

Book details
Book preview
Table of contents
Citations

About This Book

An interactive way to introduce the world of Python Programming Key Features

  • Detailed comparisons and differentiation of python language from other most popular languages C/C++/Java.
  • Authentic and extensive set of programming illustrations in every chapter of the book.
  • Broad study on all the programming constructs of the python programming language such as native data types, looping, decision making, exception handling, file handling etc.
  • Broad study of Python Object Oriented Programming features with illustrations.
  • Numerous review questions and exercises at the end of every chapter.

  • Description
    This Book is meant for wide range of readers who wish to learn the basics of Python programming language. It can be helpful for students, programmers, researchers, and software developers. The basic concepts of python programming are dealt in detail. The various concepts of python language such as object-oriented features, operators, native data types, control structures, functions, exception handling, file handling, etc are discussed in detail with the authentic programming illustration of each.presently, python programming is a hot topic among academician's researchers, and program developers. As a result, the book is designed to give an in-depth knowledge of programming in python. This book can be used as handbook as well as a guide for students of all computer science stream at any grade beginning from 10+1 to Research in PhD. To conclude, we hope that the readers will find this book a helpful guide and valuable source of information about python programming. What You Will Learn
  • Python Data Types, Input Output
  • Operators and Expressions
  • Control Structures
  • Python Functions, Modules
  • Exception Handling
  • File Management, Classes and Objects
  • Inheritance, Python Operator Overloading

  • Who this book is for
    Students, Programmers, researchers, and software developers who wish to learn the basics of Python programming language. Table of Contents
    1. Introduction to Python Language
    2. Python Data Types and Input Output
    3. Operators and Expressions
    4. Control Structures
    5. Python Native Data Types
    6. Python Functions
    7. Python Modules
    8. Exception Handling
    9. File Management in Python
    10. Classes and Objects
    11. Inheritance
    12. Python Operator Overloading About the Author
    Dr. Pooja Sharma completed her bachelor's degree in computer applications in 2005 with 4th position in the University and master's degree in computer science in 2007 with Gold Medal for securing first position from Guru Nanak Dev University, Amritsar.

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Programming in Python an online PDF/ePUB?
Yes, you can access Programming in Python by Dr. Pooja Sharma in PDF and/or ePUB format, as well as other popular books in Computer Science & Programming in Python. We have over one million books available in our catalogue for you to explore.

Information

CHAPTER 1

Introduction to Python Language

Highlights

  • Introduction and history of Python language
  • Features of Python
  • Applications of Python
  • Python interactive help
  • Installing and executing Python
  • How Python differ from other languages
We see that computers are capable of solving numerous problems of the real world. The problems can be as simple as to multiply two numbers or as cumbersome as to design and launch a space shuttle. This would be incorrect to assume that the computer can do all the tasks on its own. Any problem whose solution is not identified cannot be solved by a computer. The computer merely works on the set of instructions given to it by a programmer. If the computer does not understand the instructions then errors may occur and solution cannot be obtained. Therefore, it is keen responsibility of the programmer to devise a solution by giving correct instructions to the computer.

1.1. Programming Language

In order to solve a problem using computer, the programmer writes the instructions which are understandable by the computer. The computer understands only digital data either ‘0’ or ‘1’. The most basic language is the machine language that uses binary ‘0’ and ‘1’., which a computer can understand and execute very fast without using any translator (compiler or interpreter). However, it is quite difficult to code a program in machine language. The high level languages such as (C, C++, Java) are very simple to understand by humans because these languages use English language like statements. However, an additional program such as a compiler or interpreter is required to convert the high level language into machine language. Therefore, high level languages are slower than machine languages.
In other words, we can say that people express themselves using a language that has many words. Computers use a simple language that consists of strings of 0s and 1s, with a 1 representing “on” and a 0 representing “off.”. The programming language works as a translator between you and the computer. Rather than learning the computer's native language (called as machine language), one can make use of a programming language to instruct the computer in a way that is easier to learn and understand.
Every programming language has a particular structure with a specific syntax and semantics. Programming language is something like a code for writing down the instructions that a computer will follow. In fact, programmers often refer to their programs as computer code, or the process of implementing an algorithm. Alike other high level languages such as C, C++, Java, Python is also a programming language. In this book, we will learn Python programming language in detail.

1.2. History of Python Language

Python is a very powerful high-level, object oriented programming language. It was developed by Guido Van Rossum during 1985-1990 at the national research institute for mathematics and computer science in Netherlands. It is the derivative of several other languages such as ABC, Modulo-3, C, C++, Algol-68, SmallTalk and Unix Shell. ABC is a general-purpose programming language or programming environment, which had been developed in Netherlands, Amsterdam, at the CWI (Centrum Wiskunde & Informatica). The greatest achievement of ABC was to influence the design of Python.
The source code of Python language is available under GNU i.e., General Public License (GPL). The Python is a very easy to use language with simple syntax, which makes it perfect language for beginners. It is an interpreter based language. Interpreter is a program that converts high level program into low level program, i.e., machine code. It is designed to be highly readable because it uses English keywords very frequently whereas other languages use punctuations. Moreover, it has fewer syntactical constructions than other languages.
Guido Van Rossum published the first version of Python code (version 0.9.0) in February 1991. This release included already exception handling, functions, and the core data types of list, dict, str and others. Python was developed to be module as well as object oriented language. Another version 1.0 of Python was released in January 1994. The major new features included in this release were the functional programming tools lambda, map, filter and reduce, which Guido Van Rossum never liked. Six and a half years later in October 2000, Python 2.0 was introduced. This release included list comprehensions, a full garbage collector and it had the support for Unicode. Python flourished for another 8 years in the versions 2.x before the next major release as Python 3.0 (also known as “Python 3000” and “Py3K”). Python 3 is not backwards compatible with Python 2.x. The emphasis in Python 3 had been on the removal of duplicate programming constructs and modules.

1.3. Origin of Python Programming Language

At the time when he began implementing Python, Guido van Rossum was reading the published scripts from “Monty Python's Flying Circus” (a BBC comedy series from the seventies). It occurred to him that he needed a name that should be short, unique, and slightly mysterious, so he decided to call the language Python.

1.4. Features of Python

The Python language exhibits numerous features, which are detailed as under:
Beginner 's Language: Python is a great language for beginner level programmers, which supports the development of a wide range of applications from simple text processing to web browsers to games.
Easy to Learn: Python has simple structure, a few keywords, and clearly defined syntax.
Easy to Read: It is clearly defined language that is a non-programmer understands it very easily.
Easy to Maintain: The source code of Python language is quite easy to maintain.
Interpreted: It is interpreter based language. The programmer does not need to compile the code before executing the program similar to PERL and PHP. Python has a built-in debugging feature.
Interactive: Python programs can be directly written to the Python prompt by which user directly interacts with the interpreter.
Object Oriented: It supports object oriented style of programming that encapsulates code within objects. OOP breaks up code into several units that pass messages back and forth using classes.
Versatile: Python modules are capable to work with multiple operating systems and user interfaces including images and sounds.
Broad Standard Library: Python language 's bulk library is portable and cross platform compatible with UNIX, Windows and Macintosh.
Interactive Mode: Python language has support for interactive mode, which allows interactive testing and debugging of code.
Portable: Python language can be executed on wide variety of hardware platforms and has similar interface on all the platforms.
Databases: Python language provides the facility of interfaces to all major commercial databases.
GUI Programming: Python provides graphical user interface (GUI) applications that can be created and ported to many system calls, libraries and Windows systems such as Windows MFC, MAC, and the X Window system of Unix.
Scalable: It provides a better structure and support for large programs.

1.5. Limitations of Python

As we see, Python language has many features, it has some limitations also as under:
  • Python is an interpreter based language. Therefore, it is bit slower than compiler based languages.
  • Since, Python is a high level language like C/C++/Java, it also uses many layers to communicate with the operating system and the computer hardware.
  • Graphics intensive applications such as games make the program to run slower.

1.6. Major Applications of Python

The list of companies that use Python include the following:
  • Yahoo! (for Yahoo! Maps)
  • Google (for its spider and search engine)
  • Linux Weekly News (published by using a web application written in Python)
  • Industrial Light & Magic (used in the production of special effects for movies such as The Phantom Menace and The Mummy Returns).

1.7. Getting Python

The most up-to-date and current source code, binaries, documentation, news, etc., is available on the official website of Python: http://www.python.org/
The complete Python documentation can be obtained from the following the site www.python.org/doc/. The documentation is available in HTML, PDF and PostScript formats.

1.8. Installing Python

Python distribution is available for a wide variety of platforms. You need to download only the binary code applicable for your platform and install Python.You need a C compiler to compile the source code manually, if the binary code for your platform is not available. The installation of Python at various platforms like Unix and Linux is given as follows

1...

Table of contents