21/06/2018
Workshop on “Introduction to
Python”
Department Of
Computer Science
Engineering
SKFGI, Mankundu
,1.History
Python was developed by Guido van Rossum in the early nineties at the National
Research Institute for Mathematics and Computer Science in the Netherlands. C,
C++, ABC, Modula-3, Algol-68, SmallTalk, Unix shell and other programming
and scripting languages influenced the development of Python. Python is
copyrighted. Python source code is now available under the GNU General Public
License (GPL).
2.Features
Simple to Understand− Python offers has few keywords, simple
structure, and a clearly defined syntax. This allows the student to pick up
the language quickly.
Easy-to-read − Python code is more clearly defined and visible to the
eyes.
Easy-to-maintain − Python's source code is fairly easy-to-maintain.
A broad standard library − Python's bulk of the library is very portable
and cross-platform compatible on UNIX, Windows, and Macintosh.
Interactive Mode − Python has support for an interactive mode which
allows interactive testing and debugging of snippets of code.
Portable − Python can run on a wide variety of hardware platforms and
has the same interface on all platforms.
Extendable − You can add low-level modules to the Python interpreter.
These modules enable programmers to add to or customize their tools to
be more efficient.
Databases − Python provides interfaces to all major commercial
databases.
GUI Programming − Python supports GUI applications that can be
created and ported to many system calls, libraries and windows systems,
such as Windows MFC, Macintosh, and the X Window system of Unix.
Scalable − Python provides a better structure and support for large
programs than shell scripting.
,Apart from the above-mentioned features, Python has a big list of good
features, few are listed below-
It supports functional and structured programming methods as well as
OOP.
It can be used as a scripting language or can be compiled to byte-code for
building large applications.
It provides very high-level dynamic data types and supports dynamic type
checking.
IT supports automatic garbage collection.
It can be easily integrated with C, C++, COM, ActiveX, CORBA, and Java.
3.Basic Syntax of Python
Modes of Programming
Interactive Mode Programming
In this mode, interpreter is invoked without passing a script file as a
parameter. The codes are written in the prompt without creating any file.
Codes are written one after another in the prompt and by pressing enter
key the written code is interpreted and if no error detected, then output is
shown in the prompt; otherwise error message is displayed in the prompt.
Examples:
1.
Type the following text at the Python prompt−
>>> print("Hi Everyone")
Now, press the Enter to see the following output-
Hi Everyone
2.
Type the following text at the Python prompt−
>>> 8+3
Now, press the Enter to see the following output-
11
3.
Type the following text at the Python prompt−
, >>> 8-3
Now, press the Enter to see the following output-
5
4.
Type the following text at the Python prompt−
>>> 8*3
Now, press the Enter to see the following output-
24
5.
Type the following text at the Python prompt−
>>> 8/3
Now, press the Enter to see the following output-
2.6666
6.
Type the following text at the Python prompt−
>>> 8//3
Now, press the Enter to see the following output-
2
7.
Type the following text at the Python prompt−
>>> 9%2
Now, press the Enter to see the following output-
1
8.
Type the following text at the Python prompt−
>>> 7**2
Now, press the Enter to see the following output-
49
9.
Type the following text at the Python prompt−
>>> base=10
Press Enter