0% found this document useful (0 votes)
5 views22 pages

Python Basics

Uploaded by

navincolin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views22 pages

Python Basics

Uploaded by

navincolin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 22

IXth

Python (UNIT 3)
Python is a high level programming language,
that means it is written in English type of
statement which is easy for us to understand,
and called so.
It was develop by Guido Van Rossum in
February 1991.
We can download Python with the
following link:

https:// www.python.org/downloads/
To launch Python on our computer,

Click on Start>Python>IDLE (Python ver)


Working in Python:
There are two modes in Python to write the program.
Interactive And Script mode.

Interactive Mode :
In the interactive mode, we write code line by line into the Python
interpreter. This interactive mode is the default mode that appears when
we launch Python. It contains triple angular bracket (>>>), which is
known as Python PROMPT. After typing the command or syntax, we
need to press the enter key which gives the output or result at a time.
Such as after writing 2 + 3 and pressing enter will give 5 as result.
Script Mode :
Script Mode is used for writing block of codes, multiple lines of code, or
lengthy programs in Python. This mode is used when we want to save
our program for future use.
For saving our program in script mode, we need to give the file name
with .py extension.
To open the script mode, first we need to launch Python and click on File
>new file. The shortcut for opening new file is CTRL+N. It will open a
blank file, named untitled.
To run the python code in script mode we need to select run module
from the run menu or the shortcut is by pressing the F5 key. The output
of the Python program will be shown in the Python shell window.
Fundamental of Python:
Python is an interpreted language.
Python interpreter reads the Source Code line by line and convert it into
object Code (machine language). After processing, the interpreter again
converts the machine Code in to human readable form.
Features of Python:
(i) Free
(ii) Extensible
(iii) object oriented
(iv) Portable
(v) Embeddable
(vi) Dynamically-typed Language.
(1) Free: It is a Free and open Source language. That
means we can download and install it on our
computer, without paying any fee.
Open Source means, its source code is available for
us and we can freely distribute the copies of this
language, reads its Source code and make Changes
to it as per our requirement.
(2) Extensible: means, it allows us to extend its
Capabilities by writing parts of our program in
other languages like C and C++ and then
integrating that code into our Python Program.
(3) Object Oriented: means, it is a language that is based on the
Concept of "objects"-real world entities that have properties
(data) and behaviours (functions/methods).
In OOP, we create classes to define objects and then we Create
objects (instances) from those classes.
OOP provide us Encapsulation, Inheritance (Reusing Code from
one class to other), Polymorphism (same function behaves
differently on different objects) and Abstraction (Hiding Complex
implementation and showing only necessary details).
(4) Portable: It is a platform-independent language.
It can run on any platform without making any Changes
to them. It can be ported on Linux, windows,
Macintosh, Solaris etc.
(5) Embeddable:
we can embed Python Code inside
programs Written in other programming
languages like C or C++. This way we can
take advantage of the strength of both the
languages.
(6) Dynamically- typed language: Means no need
to declare the type of the variable before their use
while programming.

The type is determined by Python itself during run


time.
Why Python for AI?
- Easy, Simple and fast to learn and Code.
- Compatible with other programming languages, as well as Operating
Systems (platform independent).
-Many organisations and researchers use Python extensively for AI
related projects.
-It includes a large number of libraries for Al.
-Easy to find help, tutorials and Open Source Code because of
thousands of developers Contribute to Al in Python.
Applications of Python
-web Development
- Artificial Intelligence and Machine Learning
- Data Science and Data Analysis
-Automation /Scripting
-Game Development
-Desktop Applications
-Cyber security and Ethical Hacking
-IoT (Internet of Things)
-Scientific and Numeric computing
-Finance and Fintech (finance technology)
Working in Python:
There are two modes in Python to write the program. Interactive
And Script mode.
Interactive Mode :
In the interactive mode, we write code line by line into the
Python interpreter. This interactive mode is the default mode that
appears when we launch Python. It contains triple angular
bracket (>>>), which is known as Python PROMPT. After typing
the command or syntax, we need to press the enter key which
gives the output or result at a time. Such as after writing 2 + 3
and pressing enter will give 5 as result.
Script Mode :
Script Modi is used for writing block of codes,
multiple lines of code, or lengthy programs in
Python. This mode is used when we want to save
our program for future use. For saving our program
in script mode, we need to give the file name with.
py extension.
To open the script mode, first we need to launch Python and click
on File >new file. The shortcut for opening new file is CTRL+N. It
will open a blank file, named untitled. To run the python code in
script mode we need to select run module from the run menu or
the shortcut is by pressing the F5 key. The output of the Python
program will be shown in the Python shell window.
Python character set:
Python character set also known as charset. It can be
defined as a set of valid characters that can be used in
Python program to write the source code. It can contain
digits, Characters and symbols, that are used to construct
words, sentences, statements in a program.
Examples:
English alphabets A-Z, a-z, Digits from 0 to 9, Special symbols
such as +, -, =, _, *, &, #, <=, >=
Whitespace such as blank space, tab space, carriage return,
newline etc.
Python statements:

Statement is a line of code that we write to carry out a task in


Python.
When a statement contains operands and operators then it is
known as expression.
statements are of two types in Python
single line and multiline.
single line statements are generally written in single line and
multiline statements are written in multiple lines.
There are various ways to write multi-line statements.

You might also like