Department of Electronics and Communication Engineering
PRESENTATION BY:
A.K.P.Madhuri
3RD YEAR ECE-C
320126512118
Need of programming Languages
Computers can execute tasks very rapidly. They
can handle a greater amount of input data than
you can. But they can not design a strategy to
solve problems for you.
Need one programming language to
communicate with computer to solve the
problem.
• Abstract
• Easy-to-learn − Python has few keywords,
simple structure, and a clearly defined syntax.
• Easy-to-read − Python code is more clearly
defined and visible to the eyes.
• Easy-to-maintain − Python's source code is
fairly easy-to-maintain.
• High level language −As python is a high
level language ,we don’t need to remember its
architecture and no need to perform memory
management.
Python
 Python is popular programming language has a simple
syntax. Guido van Rossum is the creator of the Python
programming language and released in 1991
 Python works on DRY(Don't Repeat Yourself) principle.
At the same time, Python provides powerful programming
features, and is widely used.
 Companies and organizations that use Python include
YouTube, Google, Yahoo, and NASA.
Advantages of Python
 Portable
 Extendable
 Object oriented
 Dynamically typed
 Free and open source
 Easily integrated with C, C++ and Java.
Disadvantages of Python
Python is Slow at Runtime
 Python is measurably slower at runtime compared to other
programming languages like Java, C++.
Memory consumption
• Python’s memory consumption is high due to flexibility of data types
Weak in mobile computing
• Python is not best one for mobile development because it is not
memory efficient
Difficulty in using other languages
• Many Python programmers do not enjoy coding with other
programming languages. This is because they feel that other
languages are much more difficult to use. They might be used to
code with Python, which is the easiest programming language.
Variables
 Variables are nothing but reserved memory locations to store values.
This means that when you create a variable you reserve some space in
memory.
 Based on the data type of a variable, the interpreter allocates memory
and decides what can be stored in the reserved memory. Therefore, by
assigning different data types to variables, you can store integers,
decimals or characters in these variables.
Rules for Python variables:
 A variable name must start with a letter or the underscore character
 A variable name cannot start with a number • A variable name can only
contain alpha-numeric characters and underscores (A-z, 0-9, and _ )
 Variable names are case-sensitive (age, Age and AGE are three different
variables)
Strings
 Strings in Python are identified as a contiguous set of
characters represented in the quotation marks.
 Python allows for either pairs of single or double
quotes.
 'hello' is the same as "hello".
 There are many methods to operate on String.
Strings
S.no Method name Description
1 isalnum() Returns true if string has at least 1 character and all
characters are alphanumeric and false otherwise.
2 isalpha() Returns true if string has at least 1 character and all
characters are alphabetic and false otherwise.
3 isdigit() Returns true if string contains only digits and false
otherwise.
4 islower() Returns true if string has at least 1 cased character and
all cased characters are in lowercase and false
otherwise.
5 isnumeric() Returns true if a string contains only numeric
characters and false otherwise.
6 isspace() Returns true if string contains only whitespace
characters and false otherwise.
7 istitle() Returns true if string is properly “titlecased” and false
otherwise
S.no Method name Description
8 isupper() Returns true if string has at least one cased
character and all cased characters are in uppercase
and false otherwise.
9 replace Replaces all occurrences of old in string with new or
at most max occurrences if max given.
10 find() Finding the index of the first occurrence of a string
in another string
11 count() Occurrence of a string in another string
12 swapcase() Converts lowercase letters in a string to uppercase
and viceversa
13 split() Splits string according to delimiter str (space if not
provided) and returns list of substrings;
14 startswith(str,
beg=0,end=le
n(string))
Determines if string or a substring of string (if
starting index beg and ending index end are given)
starts with substring str; returns true if so and false
otherwise.
Keywords
A keyword is an identifier that has pre-defined meaning in a
programming language.
Data Types
 Python's data types are built in the core of the language
 They are easy to use and straightforward.
 Data types supported by Python
 Lists are just like dynamic sized arrays, declared in other Lists need
not be homogeneous always which makes it the most powerful tool in
python.
 Tuple: A Tuple is a collection of Python objects separated by commas.
In some ways, a tuple is similar to a list in terms of indexing, nested
objects, and repetition but a tuple is immutable, unlike lists that are
mutable.
 Set: A Set is an unordered collection data type that is iterable, mutable,
and has no duplicate elements. Python’s set class represents the
mathematical notion of a set.
 Dictionary: in Python is an ordered collection of data values, used to
store data values like a map, which, unlike other Data Types that hold
only a single value as an element, Dictionary holds key:value pair. Key-
value is provided in the dictionary to make it more optimized.
 List, Tuple, Set, and Dictionary are the data structures in python that
are used to store and organize the data in an efficient manner.
Decision control on python
Conditional (if)
The if statement contains a logical expression using which
data is compared and a decision is made based on the
result of the comparison.
Syntax:
If expression:
statement(s)
If the boolean expression evaluates to TRUE, then the block
of statement(s) inside the if statement is executed. If
boolean expression evaluates to FALSE, then the first set of
code after the end of the if statement(s) is executed.
 Alternative if (If-Else): An else statement can be combined
with an if statement. An else statement contains the block of
code (false block) that executes if the conditional expression in
the if statement resolves to 0 or a FALSE value. The else
statement is an optional statement and there could be at most
only one else Statement following if.
 Syntax of if - else :
if test expression:
Body of if stmts
else:
Body of else stmts
Chained Conditional: (If-elif-else)
 The elif statement allows us to check multiple expressions for
TRUE and execute a block of code as soon as one of the
conditions evaluates to TRUE. Similar to the else, the elif
statement is optional. However, unlike else, for which there can
be at most one statement, there can be an arbitrary number of
elif statements following an if.
 Syntax of if – elif - else :
If test expression:
Body of if stmts
elif test expression:
Body of elif stmts
else:
Body of else stmts
In Python Iteration (Loops) statements are of three types:
1. While Loop
2. For Loop
3. Nested For Loops
While loop:
Loops are either infinite or conditional. Python while loop keeps
reiterating a block of code defined inside it until the desired
condition is met. • The while loop contains a boolean expression
and the code inside the loop is repeatedly executed as long as the
boolean expression is true. • The statements that are executed
inside while can be a single line of code or a block of multiple
statements.
Syntax: while(expression):
Statement(s)
For loop:
Python for loop is used for repeated execution of agroup of
statements for the desired number of times. It iterates over the
items of lists, tuples, strings, the dictionaries and other iterable
objects
Applications of python
 Web Applications
 Game development
 Audio or Video-based Applications
 3D CAD Applications
 Image Processing Application
 Desktop GUI
 Machine Learning and Artificial Intelligence
Python ppt_118.pptx

Python ppt_118.pptx

  • 1.
    Department of Electronicsand Communication Engineering PRESENTATION BY: A.K.P.Madhuri 3RD YEAR ECE-C 320126512118
  • 4.
    Need of programmingLanguages Computers can execute tasks very rapidly. They can handle a greater amount of input data than you can. But they can not design a strategy to solve problems for you. Need one programming language to communicate with computer to solve the problem.
  • 5.
    • Abstract • Easy-to-learn− Python has few keywords, simple structure, and a clearly defined syntax. • Easy-to-read − Python code is more clearly defined and visible to the eyes. • Easy-to-maintain − Python's source code is fairly easy-to-maintain. • High level language −As python is a high level language ,we don’t need to remember its architecture and no need to perform memory management.
  • 6.
    Python  Python ispopular programming language has a simple syntax. Guido van Rossum is the creator of the Python programming language and released in 1991  Python works on DRY(Don't Repeat Yourself) principle. At the same time, Python provides powerful programming features, and is widely used.  Companies and organizations that use Python include YouTube, Google, Yahoo, and NASA.
  • 7.
    Advantages of Python Portable  Extendable  Object oriented  Dynamically typed  Free and open source  Easily integrated with C, C++ and Java.
  • 8.
    Disadvantages of Python Pythonis Slow at Runtime  Python is measurably slower at runtime compared to other programming languages like Java, C++. Memory consumption • Python’s memory consumption is high due to flexibility of data types Weak in mobile computing • Python is not best one for mobile development because it is not memory efficient Difficulty in using other languages • Many Python programmers do not enjoy coding with other programming languages. This is because they feel that other languages are much more difficult to use. They might be used to code with Python, which is the easiest programming language.
  • 9.
    Variables  Variables arenothing but reserved memory locations to store values. This means that when you create a variable you reserve some space in memory.  Based on the data type of a variable, the interpreter allocates memory and decides what can be stored in the reserved memory. Therefore, by assigning different data types to variables, you can store integers, decimals or characters in these variables. Rules for Python variables:  A variable name must start with a letter or the underscore character  A variable name cannot start with a number • A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )  Variable names are case-sensitive (age, Age and AGE are three different variables)
  • 10.
    Strings  Strings inPython are identified as a contiguous set of characters represented in the quotation marks.  Python allows for either pairs of single or double quotes.  'hello' is the same as "hello".  There are many methods to operate on String.
  • 11.
    Strings S.no Method nameDescription 1 isalnum() Returns true if string has at least 1 character and all characters are alphanumeric and false otherwise. 2 isalpha() Returns true if string has at least 1 character and all characters are alphabetic and false otherwise. 3 isdigit() Returns true if string contains only digits and false otherwise. 4 islower() Returns true if string has at least 1 cased character and all cased characters are in lowercase and false otherwise. 5 isnumeric() Returns true if a string contains only numeric characters and false otherwise. 6 isspace() Returns true if string contains only whitespace characters and false otherwise. 7 istitle() Returns true if string is properly “titlecased” and false otherwise
  • 13.
    S.no Method nameDescription 8 isupper() Returns true if string has at least one cased character and all cased characters are in uppercase and false otherwise. 9 replace Replaces all occurrences of old in string with new or at most max occurrences if max given. 10 find() Finding the index of the first occurrence of a string in another string 11 count() Occurrence of a string in another string 12 swapcase() Converts lowercase letters in a string to uppercase and viceversa 13 split() Splits string according to delimiter str (space if not provided) and returns list of substrings; 14 startswith(str, beg=0,end=le n(string)) Determines if string or a substring of string (if starting index beg and ending index end are given) starts with substring str; returns true if so and false otherwise.
  • 14.
    Keywords A keyword isan identifier that has pre-defined meaning in a programming language.
  • 15.
    Data Types  Python'sdata types are built in the core of the language  They are easy to use and straightforward.  Data types supported by Python
  • 16.
     Lists arejust like dynamic sized arrays, declared in other Lists need not be homogeneous always which makes it the most powerful tool in python.  Tuple: A Tuple is a collection of Python objects separated by commas. In some ways, a tuple is similar to a list in terms of indexing, nested objects, and repetition but a tuple is immutable, unlike lists that are mutable.  Set: A Set is an unordered collection data type that is iterable, mutable, and has no duplicate elements. Python’s set class represents the mathematical notion of a set.  Dictionary: in Python is an ordered collection of data values, used to store data values like a map, which, unlike other Data Types that hold only a single value as an element, Dictionary holds key:value pair. Key- value is provided in the dictionary to make it more optimized.  List, Tuple, Set, and Dictionary are the data structures in python that are used to store and organize the data in an efficient manner.
  • 17.
    Decision control onpython Conditional (if) The if statement contains a logical expression using which data is compared and a decision is made based on the result of the comparison. Syntax: If expression: statement(s) If the boolean expression evaluates to TRUE, then the block of statement(s) inside the if statement is executed. If boolean expression evaluates to FALSE, then the first set of code after the end of the if statement(s) is executed.
  • 18.
     Alternative if(If-Else): An else statement can be combined with an if statement. An else statement contains the block of code (false block) that executes if the conditional expression in the if statement resolves to 0 or a FALSE value. The else statement is an optional statement and there could be at most only one else Statement following if.  Syntax of if - else : if test expression: Body of if stmts else: Body of else stmts
  • 19.
    Chained Conditional: (If-elif-else) The elif statement allows us to check multiple expressions for TRUE and execute a block of code as soon as one of the conditions evaluates to TRUE. Similar to the else, the elif statement is optional. However, unlike else, for which there can be at most one statement, there can be an arbitrary number of elif statements following an if.  Syntax of if – elif - else : If test expression: Body of if stmts elif test expression: Body of elif stmts else: Body of else stmts
  • 20.
    In Python Iteration(Loops) statements are of three types: 1. While Loop 2. For Loop 3. Nested For Loops While loop: Loops are either infinite or conditional. Python while loop keeps reiterating a block of code defined inside it until the desired condition is met. • The while loop contains a boolean expression and the code inside the loop is repeatedly executed as long as the boolean expression is true. • The statements that are executed inside while can be a single line of code or a block of multiple statements. Syntax: while(expression): Statement(s)
  • 21.
    For loop: Python forloop is used for repeated execution of agroup of statements for the desired number of times. It iterates over the items of lists, tuples, strings, the dictionaries and other iterable objects
  • 22.
    Applications of python Web Applications  Game development  Audio or Video-based Applications  3D CAD Applications  Image Processing Application  Desktop GUI  Machine Learning and Artificial Intelligence