PYTHON INTRODUCTION
PYTHON INTRODUCTION
Introduction:-
A computer is a versatile machine that can perform millions of instructions in a
second, but can neither think nor make any decision on its own. It requires a
program to be written to instruct what needs to be done. Thus a program is a set of
instructions written in a sequence that guide a computer to solve a particular task.
Features Of Python
➢ Python is an interactive, interpreted, directly executed, with pre - compiled
code. This means that it is processed at runtime by the interpreter and you
need not compile the program before executing.
➢ It is an Object-Oriented Programming Language with few keywords and
simple English-like structure, and is easy to learn.
➢ It is a free open source and portable language having large Libraries.
➢ It takes less time to develop as Python programs are typically 3-5 times
shorter than equivalent other programming languages.
➢ It supports GUI (Graphical User Interface).
➢ Python is used for both scientific and non scientific programming.
Advantages Of Python
➢ Platform - Independent: It can run across different platforms.
➢ Readability: Python program use clear, simple and English - like instructions.
➢ Object - Oriented Language
➢ Higher Productivity: Python is a simple language with small codes and large
libraries.
➢ Less Learning Time: Because of a simple and shorter code, lesser time
required to understand and Learn python programming.
Python IDLE
To write and run Python programs interactively, we can either use the command line
window or the IDLE. IDLE is a simple Integrated Development Learning
Environment that comes with Python.
Python shell
Python shell is an interactive window where you can type Python code and see the
output in the same window.
print (): print () is a function which is used to display the specified content on the
screen. The content (called Argument) is specified within parentheses. print ()
statement without any arguments will simply jump to the next line.
Tokens in python
The smallest individual unit in a program is known as a Token or lexical unit.
Python has following tokens:
(i) Keywords
Keywords are predefined words with special meaning to the language compiler or
interpreter. These are reserved for special purpose and must not be used as normal
identifier names.
Python programming language contains the following keywords:
Note:- these highlighted keywords are always started with capital letter.
(ii) Identifiers
Identifiers are the name given to different parts of the program (variable, objects,
classes, functions, list, dictionaries etc.)
(iv) Operators
Operators are tokens that trigger some computation / action when applied to variable
and other objects in an expression.
Arithmetic operators ( + , - , * , / , // , ** , % )
Relational operators ( > , < , >= , <= , == , != )
Logical operators ( and, or )
Identity operators ( is,, is not )
Assignment operators ( = )
Membership operators ( in , not in )
Arithmetic - assignment operators ( ( += , - = , *= , /= , //= , **= , %= )
Bitwise operators (& , ^ , | )
Shift operator (<< , >> )
Punctuators
Punctuators are symbols that are used in programming language to organise
sentence structure.
Most common punctuators of python programming language are:
'"#\(){}[]@,:.`=
Dynamic Typing is different from Static Typing, a data type is attached with a
variable when it is defined first and it is fixed. That is, data type of a variable cannot
be changed in static typing whereas there is no such restrictions in dynamic
typing, which is supported by Python.
Data Types
Python offers the following data types to store and process different types of numeric
data: Integer, Float, Complex Number, String, Lists, Tuples, Dictionaries.
Immutable Types: Those data types that can never change their value in place.
Ex. Integers, floating point numbers, Boolean, string, tuples.
Mutable Types: Mutability means that in the same memory address, new values can
be stored as and when you want.
Ex. Lists, dictionaries and sets.