Introduction to Python | Basic Python Components

What is Python

Python is an object oriented Programming Language developed by Guido Van Rossum in February 1991. It is basically influenced from two languages namely ABC and Modula-3.

Why it is named Python

Python is not named after snake but is named after famous BBC comedy show “Monty Python’s Flying Circus”.

Who is promoting Python

It is promoted by google and top leaders of IT industry.

Features of Python

1. Expressive:

It is simple to write complex codes in Python.

For example: I need to interchange values of two variables.

Code to interchange them in C,C++,C# and Java is

int A=10,B=5,C;

C=A

A=B

B=C

In python we can do :

A,B=10,5

A,B=B,A

2. Easy to use:

It is very easy to use Python due to very simple syntax and programmer friendly nature

3. Interpreter Based Language

Syntax errors in Python are checked line by line during run time. So it is easy to find and correct errors in Python

4. Rich Library

Python has in built library for almost every kind of task including databases, GUI, Network based and web based applications.

5. Platform Independent Language

Python is a platform independent language. It can equally run on all major hardware and software platforms. Same python code can run on Windows, LINUX, Unix, Macintosh as well as smart phones.

6. Open Source Language

Python is an open source language I.e. complete inbuilt code is also available. Moreover it is free so that you can download and use it without any restrictions.

7. Diverse Area of Usage

Python is being used in different types of applications such as:

  • Web applications
  • Game development
  • GUI applications
  • Database Applications
  • Scripting Purpose
  • Prototyping



Character Set

Character set is a set of characters that a programming language recognizes.

Python has the following character set:

Letters A-Z ,a-z
Digits

0-9

 

Special symbols Space, +, -, *, /,  \, (, ) , [, ],  {, },  !, =,  < , >,’, “, ; , :,  %, &, #,  _(underscore)
White spaces Blank space,tabs ,carriage return,new line,formfeed.
Other characters Python can process all ASCII and Unicode characters as part of data or literals.

Tokens

Token is the smallest identifiable part of a program. Each individual word as well as punctuation marks within a program are called tokens

Python has following tokens:

(i) Keywords

(ii) Identifiers(Names)

(iii) Literals 

(iv) Operators 

(v) Punctuators



Keyword

Keywords are predefined words which have special meaning in Python.  Python contains the following  keywords:

False assert del for in or while
None break elif from is pass with
True class else global lambada raise yield
and continue except if nonlocal return as
try def finally import not

Identifier

Identifier is the name given to different parts of a program. They  include variables, objects, classes, functions, lists, dictionaries etc.

Rules to name an identifier in Python are :

  1. An identifier is a long sequence of letters and digits.
  2. The first character must be an alphabet or underscore(_).
  3. Upper and lower –case letters are different.
  4. Identifier can contain digits from 0 to 9. But identifier name can’t start with a digit.
  5. Identifiers are unlimited in length.
  6. It must not be a keyword of python .
  7. An identifier cannot contain any special character other than underscore(_).

Examples of valid identifiers:

Myprogram  date1_17_2019 at0z
Father_name Rs100

Examples of invalid identifiers:

A-One It can’t contains special character (hyphen).
29CLCT  Starting with a digit.
break                    Keywords can’t be used.
file1.txt Special character (.) not allowed.

Punctuators

Punctuators are special symbols provided by Python to organize statements, expressions and program structure.

 Different punctuators provided by Python are:

’  “   #  \  (  )  {  }  @ ,  :  .  `  =  ;



Spread the love
Lesson tags: Introduction to Python, learn python, Python for beginners, Python Introduction, python tutorial
Back to: Python Programming Tutorial
Spread the love