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

PYTHON INTRODUCTION

The document provides an introduction to Python, an open-source, high-level programming language created by Guido Van Rossum in 1991. It outlines Python's features, advantages, and components, including tokens, data types, and the difference between mutable and immutable types. Additionally, it explains the use of Python IDLE for writing and executing code, as well as the concepts of dynamic and static typing.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

PYTHON INTRODUCTION

The document provides an introduction to Python, an open-source, high-level programming language created by Guido Van Rossum in 1991. It outlines Python's features, advantages, and components, including tokens, data types, and the difference between mutable and immutable types. Additionally, it explains the use of Python IDLE for writing and executing code, as well as the concepts of dynamic and static typing.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

GETTING STARTED WITH PYTHON

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.

Python Programming Language


Python is an open source, object- oriented, high level programming language
developed by Guido Van Rossum in 1991 at the National Research Institute for
Mathematics Netherlands. Python based on ABC language created to replace the
programming language BASIC.

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.

Note: you can write code in interactive mode or script mode.

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 (ii) Identifiers (iii) Literals (iv) Operators


(v) Punctuators

(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:

False assert del for in or while

None break elif from is pass with

True class else global lambda raise yield

and continue except if nonlocal return

as def finally import not try

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.)

The naming rule for Python Identifiers are


➢ Names must only be a non-keywords word with no space between.
➢ Names must be made up of only letters, numbers, and underscores (_).
➢ Names cannot begin with a number, although they can contain numbers.
➢ Python is a case-sensitive language.
(iii) Literals
Literals are data items has a fixed / constant value.
String literals (single line or multiline string)
Numeric literals ( int, float, octal, hexadecimal )
Boolean literals ( True, False)
Special literals ( None absence of value )

(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:
'"#\(){}[]@,:.`=

Various Components of Python

➢ Expression: Which are any legal combination of symbols that represents a


value.
➢ Statement: Which are programming instructions.
➢ Comments: Which are the additional readable information to clarify the
source code. Comment can be Single line comments, that starts with # and
multi - line comments that can be either triple - quoted strings or multiple #
style comments.
➢ Function: Which are named code - sections and can be reused by specifying
their names (function calls).
➢ Block(s): Which is a group of statements which are part of another statement
or a function. All statements inside a block or suite are indented at the same
level.
Dynamic Typing vs. Static Typing

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.

MUTABLE AND IMMUTABLE TYPE


The Python data objects can be broadly categorised into two - mutable and
immutable types, in simple words changeable or not changeable types.

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.

You might also like