KEMBAR78
Introduction To Python | PDF | Python (Programming Language) | Integrated Development Environment
0% found this document useful (0 votes)
5 views25 pages

Introduction To Python

Uploaded by

adityareader0
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)
5 views25 pages

Introduction To Python

Uploaded by

adityareader0
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/ 25

INTRODUCTION TO PYTHON

PROGRAMMING LANGUAGE
 Python is an interesting, general purpose, high-level, interpreted
programming language
 It is developed by Guido Van Rossum in February 1991.
 It is an easy to learn, playful language with powerful and
distinctive object oriented language (OOP) features.
 Python is a case-sensitive language (Uppercase and Lowercase
letters are treated differently)
 Python has its close connections with two programming languages:
 ABC Language (which replaced BASIC)
Modula-3
Python was named after famous BBC Comedy Show namely
Monty Python’s Flying Circus.
Why Python?
ADVANTAGES OF PYTHON
 Compact and very easy to use language
 Simple syntax rules( programmer friendly)
 Object Oriented language (OOP)
 High level Interpreted language
 Free and Open Source Language
 Complete and expressive language
 Cross-platform language
 Diverse language with wide applications
 Software development, Data warehousing & Mining
 Web development (server-side)  Scientific Computing,
 Data Analysis  Mathematical Applications
 Data Science  Artificial Intelligence, Robotics
LIMITATIONS of Python
 Slower than many languages
(Python programs are first semi-compiled and then interpreted
which makes it slower. But, it has faster development times due to
lesser syntax writing)
 Lesser libraries than other programming languages
(Python has less library support than others)
 Weak in Data Type-Binding
(a variable can be declared using multiple data types which is a
Type-mismatch situation))
 Not easily convertible
(tough to convert from Python to other programming languages
like C++ as others have a strong syntax)
About IDE (Integrated Development
Environment)
What Are IDEs and Code Editors? Python
An IDE (or Integrated Interpreters
Development Environment) is a
program dedicated to software Python Charm IDE
development. As the name implies, Anaconda
IDEs integrate several tools specifically Distribution for
designed for software development. Python IDE
These tools usually include: CPython.
• An editor designed to handle code IronPython.
(with, for example, syntax highlighting Jython.
and auto-completion)
PyPy.
• Build, execution, and debugging tools
PythonNet.
• Some form of source control
Stackless Python.
INSTALLING PYTHON
https://www.python.org/downloads/
1. Open 2. Click here on the setup file
(.exe) of Python
DOWNLOADS of
your computer

3. Check
this box and
select 4. Click here on
“ADD
INSTALL NOW
PYTHON3.8
TO PATH”
SET UP will prompt
you to choose
…whether you
want to INSTALL or
not.
YES/NO
5. Installing
Choose YES

6. Set up successful
7. CLICK START BUTTON and open Python 3.8 (IDLE)

8. Python prompt (Python Interpeter) .


Here, you can write your code.
Pyroid for MOBILE- to run python
codes
MODES of PYTHON
Introduction to Python
Why Python?: There are two distinct modes of Python:
Advantages
Limitations of Python I. INTERACTIVE MODE
Installing Python

Modes of Python
Getting familiarized II.SCRIPT MODE
with elements of Python
MODES of PYTHON

I. INTERACTIVE MODE
Write your code here in the interactive mode

Python Interpreter prompt denoted by >>>


MODES of PYTHON

II. SCRIPT MODE


Write your code here in the UNTITLED
file open for you (Programmer).
MODES of PYTHON
OUTPUT
STRUCTURE OF A PROGRAM IN PYTHON
Reusable
code
Importing
Libraries

Function COMMENTS
Definition (non
executable
codes)

Expression

Statements

Main
Expression
Program
Indentation Expression
(Indented
Block of
code)
(COMPONENTS/ STRUCTURE/
BAREBONES) OF A PYTHON PROGRAM
 EXPRESSIONS: Any legal combination of symbols that represent a
value.
 STATEMENTS: Any programming instruction that does some work or
some action that takes place.
 FUNCTIONS: A code that can be executed again and again (can be
reused) by calling with the name of the function
wherever needed in the program.
 BLOCKS AND INDENTATIONS: A group of statements which are part
of another statement or a function are called block or
code-block. Indentation (spaces/gaps )in front of the
statements create block. The statements under the
same block must be indented at the same level of
indentation. Indentation without reason in a statement
raises error in a program.
 COMMENTS: Please turn over to the next page to know comments in details
Comments
 Comments are the non-executable statements which are ignored by the language compiler
or interpreter. It is read by the programmers and given by them for the convenience of the
programmer.
 Comments are the additional readable information which are given for the understanding
of the user and gives information about the source code.
Comments are of two types:
1) SINGLE LINE COMMENT 2) MULTILINE COMMENT

Comments enclosed in triple (""") or triple apostrophe(' ' ') are called docstrings.
We can use either triple-apostrophe ar triple quotes(""") to write docstrings.
PYTHON CHARACTER SET
A set of valid characters recognized by python. Python
uses the traditional ASCII character set. The latest
version recognizes the Unicode character set. The
ASCII character set is a subset of the Unicode
character set.
• Letters :- A-Z , a-z
• Digits:- 0-9
• Special symbols :- Special symbol available over
keyboard
• White spaces:- blank space, tab, carriage return, new line,
form feed
• Other characters:- Unicode
TOKENS
IN PYTHON
TOKENS
Smallest individual unit in a program is called a token.
They are:

 K eywords
 I dentifiers
 L iterals
 P unctuators
 O perators
My funda of remembering Tokens: KILPO it’s just a shortcut given by me for remembrance ;)
TOKEN KEYWORDS
Keywords are the words that convey a special meaning to the
language compiler/interpreter. They are reserved for special
purpose and must not be used as normal identifier names.
and exec not
as finally or
assert for pass
break from print
class global raise
continue if return
def import try
del in while
elif is with
else lambda yield
except
TOKEN IDENTIFIERS
Identifiers are the fundamental building blocks of a program which
are used to identify a variable, function name, class name, module
name or any object.
RULES OF WRITING AN IDENTIFIER
 An identifier starts with a letter A to Z, a to z or an underscore ( _ ) followed by
zero or more letters, underscores and digits (0 to 9).
 Identifier name canNOT start with a digit.
 Python does NOT allow special characters other than underscore ( _ ).
 Identifier must NOT be a keyword of Python.
 Python is a case sensitive programming language that is uppercase letters
(capital letters) and lowercase letters (small letters) are treated differently.
Eg. Marks and marks are two different identifiers in Python.
• Some valid identifiers : Mymarks , file12 , tv9r , Avg_2 , _no

• Some invalid identifier : 4Qtr , global , XI-CS , E mail , %age

Starts with digit keyword


Special characters - (hyphen) space %
TOKEN LITERALS / values
Literals are data items that have a fixed value.
Python allows several kind of literals:
Numeric Literals
• Int (signed integers)  Positive or Negative
whole numbers with no decimal point Eg.
10, -96, 1234, 0
• Floating point/Real values  float represent
real numbers and are written with a decimal
point dividing the integer and fractional part.
Eg 2.0,54.7,-12.0,-0.075, .4
• Complex (complex numbers)  a+bj , where
a and b are floats and J(or j) represents √-1 ,
which is an imaginary number. a is the real
part and b is the imaginary part of the
number.
TOKEN LITERALS contd..

Boolean Literals
True and False are the only two Boolean
values

Special Literal None


None literal represents absence of a value.
That is why nothing is printed
for the value of b.
String Literal
String literal is a sequence of characters
surrounded by quotes (single or double or
triple)
String literals can be written in either single
quote ‘ ’ or double quote “ ”

You might also like