0% found this document useful (0 votes)
16 views

2-Salient Features of Python - II

The document discusses some salient features of the Python programming language. It describes Python's enhanced readability through use of indentation instead of curly brackets. It also discusses Python's dynamic typing where variables do not need declaration, its interpretation which allows partial output and easier error detection, and its extensibility through modules. Additional features covered are its standard database API, GUI programming capabilities, and embeddability with other technologies.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

2-Salient Features of Python - II

The document discusses some salient features of the Python programming language. It describes Python's enhanced readability through use of indentation instead of curly brackets. It also discusses Python's dynamic typing where variables do not need declaration, its interpretation which allows partial output and easier error detection, and its extensibility through modules. Additional features covered are its standard database API, GUI programming capabilities, and embeddability with other technologies.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Salient Features of Python

Let us take a closer look at some of the salient features of Python.


1. Enhanced readability
In Python, uniform indents are used to delimit blocks of statements instead of curly
brackets like in C, C++ and Java. This enhances readability.
In C, C++, Java
if (X%2==0)
{
if (x%3==0)
System.out.println("divisible by 2 and 3");
else
System.out.println("divisible by 2 not divisible by 3");
}
else
{
if (x%3==0)
System.out.println("divisible by 3 not divisible by 2");
else
System.out.println("not divisible by 3 nor by 2");
}

In Python
if num%2 == 0:
if num%3 == 0:
print ("Divisible by 3 and 2")
else:
print ("Divisible by 2 not divisible by 3")
else:
if num%3 == 0:
print ("Divisible by 3 not divisible by 2")
else:
print ("Not divisible by 3 nor by 2")
2. Dynamic typing
In Python, a variable to be used in a program need not have prior declaration of its
name and type. You will learn details about variables in the next module.

Java is statically typed Python is dynamically typed


String var; // Variable is explicitly var=”Hello” # Variable is NOT explicitly
declared. declared.
var=”Hello”; var=1234 # Allowed although variable
var=1234; // Not allowed because the was initially String type
variable has been declared as a String.

3. Interpreted language
Python is an interpreter-based language. An interpreter executes one instruction at a
time. So if there is an error on line 7 of the code, it will execute instructions till line 6
and then stop. This is unlike a compiler which will not execute any of the instructions
even if there is a single error. Thus, an interpreter is useful if you are new to
programming because it allows you to see partial output of your code and identify the
error location more easily.

Java program (Compiled) Python program (Interpreted)


//This program will not display any of the #This program will display two
phrases as there is an error on line 7. phrases but not the third phrase as
there is an error in line 3.
1 public class test
2{ print ("welcome to")
3 public static void main(String args[]) print ("Python training program from")
4 { print (Internshala)
5 System.out.println("Welcome to");
6 System.out.println("Python training
program");
7 System.out.println(From
Internshala);
8 }
9}
4. Extensible language
Python extension modules implement new built-in object types and can call C
libraries and system calls which Python doesn’t have direct access to.
5. Standard DB2 API
A standard data connectivity API facilitates using data sources such as Oracle,
MySQL and SQLite as a backend to a Python program for storage, retrieval and
processing of data.
6. GUI programming
Standard distribution of Python contains Tkinter GUI kit, which is an implementation
of the popular GUI library called Tcl/Tk. An attractive GUI can be constructed using
Tkinter. Many other GUI libraries like Qt, GTK, WxWidgets etc. are also ported to
Python.
7. Embeddable
Python can be integrated with other popular programming technologies such as C,
C++, Java, ActiveX and CORBA.

You might also like