Introduction to Python | Basic Python Components

Preview

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:

LettersA-Z ,a-z
Digits

0-9

 

Special symbolsSpace, +, -, *, /,  \, (, ) , [, ],  {, },  !, =,  < , >,’, “, ; , :,  %, &, #,  _(underscore)
White spacesBlank space,tabs ,carriage return,new line,formfeed.
Other charactersPython 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 in a programming language which have special meaning and special purpose in a language. They can not be used as identifier names. Python contains the following  keywords:

Falseassertdelforinorwhile
Nonebreakeliffromispasswith
Trueclasselsegloballambadaraiseyield
andcontinueexceptifnonlocalreturnas
trydeffinallyimportnot

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 an arbitrarily long sequence of letters and digits.
  2. The first character must be a letter: the underscore(_) counts as a letter.
  3. Upper and lower –case letters are different. All characters are significant.
  4. The digits 0 through 9 can be part of the identifier except for the first character.
  5. Identifiers are unlimited in length. Case is significant i.e.,python is case sensitive as it treats upper and lower-case characters differently.
  6. An identifier must not be a keyword of python .
  7. An identifier cannot contain any special character except for underscore(_).

Examples of valid identifiers:

Myprogram  date1_1 7_2019at0z
Father_nameRs100

Examples of invalid identifiers:

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

JOIN OUR MAIL LIST FOR

Latest Updates

Get Widget

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