CAREERERA
®
A warm welcome to Careerera family
CAREERERA
®
Introduction to Programming using Python
2
WHAT IS PYTHON
https://www.careerera.com 3
• Python is a popular programming language.
• It was created by Guido van Rossum, and released in
1991.
• It is used for:
⮚web development (server-side).
⮚ software development.
⮚mathematics.
⮚ system scripting.
WHY PYTHON IS WIDELY USE?
4
• The python language is one of the most accessible programming
languages
• Due to its ease of learning and usage, python codes can be easily
written and executed much faster than other programming
languages.
• Python works on different platforms (Windows, Mac, Linux etc).
• Python has a simple syntax.
• Python is easy to code.
• Python runs on an interpreter system, meaning that code can be
executed as soon as it is written.
• Python is a object Oriented Programming Language
DATA TYPES -NUMBERS
5
• Number data types store numeric values. They are immutable data
types, means that changing the value of a number data type results
in a newly allocated object.
• Number objects are created when you assign a value to them.
For example :−
var1 = 10
var2 = 30
BOOLEAN
6
• Python boolean type is one of the built-in data types provided by
Python, which are defined by the True or False keywords.
• The bool() method is used to return or convert a value to
a Boolean value i.e., True or False, using the standard truth testing
procedure.
7
• Strings are arrays of bytes representing Unicode characters.
However, Python does not have a character data type, a single
character is simply a string with a length of 1. Square brackets
can be used to access elements of the string. individual
characters of a String can be accessed by using the method of
Indexing.
For Example:-
value = “Careerera”
STRINGS DATATYPES
CONCATENATION IN PYTHON
8
Concatenating means obtaining a new string that contains
both of the original strings. You can use “+” operator to
concatenate strings in python.
For Example:-
9
Subset - A set of which all the elements are contained in
another set.
• The issubset() method returns True if all elements of a
set are present in another set (passed as an argument).
• If not, it returns False.
• For Example :-
SUBSET IN PYTHON
10
Position: The index() method returns the index position
of the first occurance of the specified item.
Raises a ValueError if there is no item found.
For Example:
Syntax:
list.index(element, start, end)
USES OF POSITION
VARIABLES
11
• Variables are 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.
BASIC PROGRAMMING SYNTAX
12
• Python syntax are very much simple and easy.
• Every programming language has its own set of rules that make
up its basic syntax.
• Hence ,it’s easy to code in Python.
• For Example:
print(“ Learn from Careerera “)
The syntax mention above is the basic syntax of python
programming language to print .
HELLO WORLD PROGRAM IN PYTHON
For example :
13
INTEGRATED DEVELOPMENT ENVIRONMENT(IDE) FOR PYTHON
14
• Jupyter IDE can be use for python coding.
• Jupyter is a free, open-source, interactive web tool that allows
editing and running files via a web browser.
• To launch a Jupyter notebook, open your terminal and navigate to
the directory where you would like to save your notebook.
• Then type the command Jupyter notebook and the program will
instantiate a local server at localhost:8888
DATA STRUCTURE
• Data structures are “containers” that organize and
group data according to type.
• The basic Python data structures in Python include
• list, array, tuples, and dictionary.
• Each of the data structures is unique in its own way.
LIST IN PYTHON​
16
• Lists are used to store multiple items in a single variable.
• List items are ordered, changeable, and allow duplicate values.
• The elements in a list are indexed according to a definite sequence .
• Indexing starts from 0,1,2,3 so on..
• items in a list need not be of the same type.
SYNTAX AND EXAMPLES OF LIST
17
Syntax:
Li=[] # empty list
Li1=[1,2,34,5] # list containing element’s
List Example:
18
• A tuple is a collection of objects which is ordered and immutable.
• Tuples are ordered, it means that the items have a defined order,
and that order will not change.
• Tuples are written with round brackets.
• tuples allow duplicate values.
• Tuples items can be indexed .
TUPLE IN PYTHON
SYNTAX AND EXAMPLES OF TUPLES
19
• Syntax:
• a=(1,5,8,9)
• B=(True , False , True)
• Tuple Example:
20
• Sets are used to store multiple items in a single variable.
• A set is a collection which is unordered
• Unordered means that the items in a set do not have a defined
order.
• Sets are unchangeable, meaning that we cannot change the
items after the set has been created.
• Sets are unindexed
• Sets are written with curly brackets.
SET IN PYTHON
SYNTAX AND EXAMPLES OF SETS
21
Syntax:
• a={“Apple” , “Orange” , “Banana” }
Set Example:
22
• Dictionaries are used to store data values in key:value pairs.
• A dictionary is a collection which is ordered*, changeable and
does not allow duplicates.
• Dictionary holds a pair of values
• Dictionary can also be created by the built-in function dict().
• An empty dictionary can be created by just placing to curly
braces{}.
DICTIONARIES IN PYTHON
SYNTAX AND EXAMPLES OF DICTIONARIES
23
Syntax:
• a={“keys “ :”values”, “keys “ :”values”}
Dictionary Example:
OPERATORS
24
• Operators are used to perform operations on values and
variables in Python.
• These are standard symbols used for the purpose of logical and
arithmetic operations.
• The value that the operator operates on is called the operand.
TYPES OF ARITHMETIC OPERATORS
25
• Arithmetic operators are used to perform mathematical operations like
addition, subtraction, multiplication and division.
There are 7 arithmetic operators in Python :
1. Addition
2. Subtraction
3. Multiplication
4. Division
5. Modulus
6. Exponentiation
7. Floor division
26
1. Addition Operator : In Python, + is the addition
operator. It is used to add 2 values.
Example :
ADDITION OPERATORS
27
2 . Subtraction Operator : In Python, (– )is the subtraction
operator. It is used to subtract the second value from the
first value.
Example :
SUBTRACTION OPERATORS
28
3. Multiplication Operator : In Python, * is the
multiplication operator. It is used to find the product of 2
values.
Example :
MULTIPLICATION OPERATORS
29
4. Division Operator : In Python, / is the division operator.
It is used to find the quotient when first operand is divided
by the second.
Example :
DIVISION OPERATOR
30
• 5. Modulus Operator : In Python, % is the modulus
operator. It is used to find the remainder when first
operand is divided by the second.
Example :
MODULUS OPERATOR
31
6.Exponentiation Operator : In Python, ** is the
exponentiation operator. It is used to raise the first
operand to power of second.
Example :
EXPONENTIATION OPERATOR
32
• 7. Floor division : In Python, // is used to conduct the
floor division. It is used to find the floor of the quotient
when first operand is divided by the second.
Example :
FLOOR DIVISION
LOGICAL OPERATOR
33
• Logical Operators in Python are used to perform logical
operations on the values of variables.
• The value is either true or false. We can figure out the conditions
by the result of the truth values.
• There are mainly three types of logical operators in
python : logical AND, logical OR and logical NOT.
34
Operator Description Example
and Returns True if both
statements are true
x < 5 and x < 10
or Returns True if one of
the statements is true
x < 5 or x < 4
not Reverse the result,
returns False if the result
is true
not(x < 5 and x <
10)
TYPES OF LOGICAL OPERATORS
CONDITIONAL STATEMENT
https://www.careerera.com 35
Conditional statements are also called decision-making statements.
We use those statements while we want to execute a block of code
when the given condition is true or false.
Type of condition statement in Python:
If statement.
If Else statement.
Elif statement.
Nested condition
36
Syntax is:
if(condition):
IF STATEMENT
37
• If statement is most usually used as a conditional statement.
IF ELSE STATEMENT IN PYTHON
38
• The if…else statement in Python is used
for decision making.
• The block of lines indented the same amount after
the colon (:) will be executed whenever the
condition is TRUE.
39
• If-else program:
PROGRAMS FOR IF-ELSE
ELIF STATEMENT
40
• Elif is a shortcut of else if condition statements. In Python
one or more conditions are used in the elif statement
For Example :
41
• Nested if statements means an if statement inside
another if statement.
• When a program selects one of many paths, it can use nested or
chained conditions.
For Example:
NESTED CONDITION
42
• A loop is used for iterating over a sequence (that is either a list, a
tuple, a dictionary, a set, or a string).
• With the for loop we can execute a set of statements, once for each
item in a list, tuple, set etc.
For Example:
LOOPS IN PYTHON
INTRO​ TO FOR LOOPS IN PYTHON​
43
• A for loop is used for iterating over a sequence (that is
either a list, a tuple, a dictionary, a set, or a string).
• With the for loop we can execute a set of statements,
once for each item in a list, tuple, set etc.
For Example:
PROGRAMS FOR LOOPS
44
• Loop program:
• While loop program:
45
• With the while loop we can execute a set of statements
as long as a condition is true.
For Example:
WHILE LOOP IN PYTHON
Basic Concepts of Object-Oriented
Programming In Python
46
• Object-Oriented Programming(OOP), is all about creating “objects”.
• The concept of OOP in Python focuses on creating reusable code.
• Major Python OOPs concept-
• Class.
• Object.
• Inheritance.
• Encapsulation.
Class
47
• A class is a blueprint for the object.
• It is a logical entity that has some specific attributes and
methods.
• The example for class of parrot can be :
class Parrot:
pass
• The class keyword is use to define an empty class Parrot.
• From class, we construct instances. An instance is a
specific object created from a particular class.
Object
48
• The object is an entity that has state and behavior.
• The object is an entity that has state and behavior.
• When we define a class, it needs to create an object to
allocate the memory.
Class Definition Syntax: class ClassName: # Statement-1 . . . # Statement-N
• Class Definition Syntax:
class ClassName:
# Statement-1
……
# Statement-N
ENCAPSULATION
49
• we can restrict access to methods and variables that prevents
data from direct modification which is called encapsulation.
• In encapsulation code and data are wrapped together within a
single unit .
• Encapsulation prevents your code from unauthorized user’s.
• For example:
Class Definition Syntax: class ClassName: # Statement-1 . . . # Statement-N
INHERITANCE
50
• Inheritance is the most important aspect of object-oriented
programming, which simulates the real-world concept of inheritance.
• It specifies that the child object acquires all the properties and
behaviors of the parent object.
• By using inheritance, we can create a class which uses all the
properties and behavior of another class.
TYPES OF INHERITANCE
51
FUNCTIONS
52
• A function is a block of code which only runs when it is called.
• The idea is to put some commonly or repeatedly done task together
and make a function so that instead of writing the same code again
and again for different inputs, we can call the function to reuse code
contained in it over and over again.
53
USES OF LENGTH FUNCTION
Length : len() function is an inbuilt function in Python
programming language that returns the length of the string.
Syntax:
len(string)
For Example:
54
• The filter() method constructs an iterator from elements of an
iterable for which a function returns true.
• Python's filter() is a built-in function.
• The filter function takes in two arguments
SYNTAX:
filter(function, iterable)
PROGRAM ON FILTER FUNCTION
UNDERSTANDING LAMBDA FUNCTIONS
55
• A lambda function is a small, anonymous function
that take any number of arguments but only have one
expression.
• We create them with the lambda keyword instead of the
traditional def keyword.
OVERVIEW OF MAP FUNCTIONS
56
• Map is a function that takes as an input a collection
Example:
• a list [‘BBA’,’MBA’,’BCA’], and a function e.g. upper().
• Then it will move every element of the collection through this function
and produce a new collection with the same count of elements.
SYNTAX:
map(function, iterables)
57
• The reduce() function, as the name describes, applies a given
function to the iterables and returns a single value.
• The reduce() function is defined in the functools module.
• The reduce function can take in three arguments, two of which are
required.
reduce(function, iterable [, initializer])
SYNTAX:
reduce(function, iterables)
PROGRAM ON REDUCE FUNCTION
EXPLORING COMMONLY USED BUILT IN
FUNCTIONS
58
• The min() function returns the item with the lowest value, or the
item with the lowest value in an iterable.
For Example:
59
The max() function returns the item with the highest
value, or the item with
MAX FUNCTION IN PYTHON
60
• The sort() method sorts the list ascending by default.
For Example:
SORT FUNCTION IN PYTHON
PROGRAMS USING USER DEFINED FUNCTIONS
61
• A user-defined function (UDF) is a function provided by the user of
a program or environment.
For Example:
Here sum is the user define function.
Methods
62
• A method in python is somewhat similar to a function, except it is
associated with object/classes.
• Method is called by its name, but it is associated to an
object (dependent).
• A method is implicitly passed the object on which it is invoked.
63
• For example:
PROGRAM SHOWING THE USE OF METHODS
ARGUMENT’S
64
• An argument is the value that are sent to the function when it is
called.
• Types of Arguments in Python Function Definition:
1.Default arguments :default arguments are values that are
provided while defining functions.
2.Keyword arguments: Functions can also be called using keyword
arguments , But all the keyword arguments should match the
parameters in the function definition.
3.Positional arguments: During function call, values passed
through arguments should be in the order of parameters in the
function definition. This is called positional arguments.
WORKING WITH FUNCTIONS WITH AND WITHOUT ARGUMENTS
65
Program without arguments:
66
PROGRAM WITH ARGUMENTS:
LOGIC FLOWCHARTS
(Intuitive understanding of code flow)
67
• A flowchart typically shows the flow of data in a process,
• It provides a pictorial representation of the algorithm
detailing the steps more clearly , thus flow charts are easily
understandable.
DIAGRAMATICAL REPRESENTATION OF A FLOW
CHART
68
PSEUDOCODE
69
• Pseudocode is a method of planning which enables the
programmer to plan without considering about the
syntax.
• It has no syntax like any of the programming language
and thus can’t be compiled or interpreted by the
computer.
LIST COMPREHENSION​
70
• List comprehension offers a shorter syntax when you want
to create a new list based on the values of an existing list.
For Example:
USE CASES VS LOOPS
71
• A use case is a methodology used in system analysis to identify,
clarify and organize system requirements.
• It also defines a list of steps that illustrate how a process will be
carried out in a system.
• While Loops in Python is used to iterate over a sequence
(list, tuple, string) or other iterable objects.
• Iterating over a sequence is called traversal.
PRACTICE LIST COMPREHENSIONS
72
• List Comprehensions is a very powerful tool, which creates a new list
based on another list, in a single, readable line.
FUNCTIONS WITH RETURN ITEMS
73
• A return statement is used to end the execution of the function call
and “returns” the result (value of the expression following the
return keyword) to the caller.
The statements after the return statements are not executed.
Syntax:
def fun():
statements
return [expression]
Thank You !!!
74
(USA)
2-Industrial Park Drive, E-Waldorf, MD,
20602,
United States
(USA)
+1-844-889-4054
(Singapore)
3 Temasek Avenue, Singapore 039190
info@careerera.com
www.careerera.com
(INDIA)
B-44, Sector-59, Noida
Uttar Pradesh 201301
(INDIA)
+91-92-5000-4000

1664611760basics-of-python-for begainer1 (3).pptx

  • 1.
    CAREERERA ® A warm welcometo Careerera family
  • 2.
  • 3.
    WHAT IS PYTHON https://www.careerera.com3 • Python is a popular programming language. • It was created by Guido van Rossum, and released in 1991. • It is used for: ⮚web development (server-side). ⮚ software development. ⮚mathematics. ⮚ system scripting.
  • 4.
    WHY PYTHON ISWIDELY USE? 4 • The python language is one of the most accessible programming languages • Due to its ease of learning and usage, python codes can be easily written and executed much faster than other programming languages. • Python works on different platforms (Windows, Mac, Linux etc). • Python has a simple syntax. • Python is easy to code. • Python runs on an interpreter system, meaning that code can be executed as soon as it is written. • Python is a object Oriented Programming Language
  • 5.
    DATA TYPES -NUMBERS 5 •Number data types store numeric values. They are immutable data types, means that changing the value of a number data type results in a newly allocated object. • Number objects are created when you assign a value to them. For example :− var1 = 10 var2 = 30
  • 6.
    BOOLEAN 6 • Python booleantype is one of the built-in data types provided by Python, which are defined by the True or False keywords. • The bool() method is used to return or convert a value to a Boolean value i.e., True or False, using the standard truth testing procedure.
  • 7.
    7 • Strings arearrays of bytes representing Unicode characters. However, Python does not have a character data type, a single character is simply a string with a length of 1. Square brackets can be used to access elements of the string. individual characters of a String can be accessed by using the method of Indexing. For Example:- value = “Careerera” STRINGS DATATYPES
  • 8.
    CONCATENATION IN PYTHON 8 Concatenatingmeans obtaining a new string that contains both of the original strings. You can use “+” operator to concatenate strings in python. For Example:-
  • 9.
    9 Subset - Aset of which all the elements are contained in another set. • The issubset() method returns True if all elements of a set are present in another set (passed as an argument). • If not, it returns False. • For Example :- SUBSET IN PYTHON
  • 10.
    10 Position: The index()method returns the index position of the first occurance of the specified item. Raises a ValueError if there is no item found. For Example: Syntax: list.index(element, start, end) USES OF POSITION
  • 11.
    VARIABLES 11 • Variables arereserved 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.
  • 12.
    BASIC PROGRAMMING SYNTAX 12 •Python syntax are very much simple and easy. • Every programming language has its own set of rules that make up its basic syntax. • Hence ,it’s easy to code in Python. • For Example: print(“ Learn from Careerera “) The syntax mention above is the basic syntax of python programming language to print .
  • 13.
    HELLO WORLD PROGRAMIN PYTHON For example : 13
  • 14.
    INTEGRATED DEVELOPMENT ENVIRONMENT(IDE)FOR PYTHON 14 • Jupyter IDE can be use for python coding. • Jupyter is a free, open-source, interactive web tool that allows editing and running files via a web browser. • To launch a Jupyter notebook, open your terminal and navigate to the directory where you would like to save your notebook. • Then type the command Jupyter notebook and the program will instantiate a local server at localhost:8888
  • 15.
    DATA STRUCTURE • Datastructures are “containers” that organize and group data according to type. • The basic Python data structures in Python include • list, array, tuples, and dictionary. • Each of the data structures is unique in its own way.
  • 16.
    LIST IN PYTHON​ 16 •Lists are used to store multiple items in a single variable. • List items are ordered, changeable, and allow duplicate values. • The elements in a list are indexed according to a definite sequence . • Indexing starts from 0,1,2,3 so on.. • items in a list need not be of the same type.
  • 17.
    SYNTAX AND EXAMPLESOF LIST 17 Syntax: Li=[] # empty list Li1=[1,2,34,5] # list containing element’s List Example:
  • 18.
    18 • A tupleis a collection of objects which is ordered and immutable. • Tuples are ordered, it means that the items have a defined order, and that order will not change. • Tuples are written with round brackets. • tuples allow duplicate values. • Tuples items can be indexed . TUPLE IN PYTHON
  • 19.
    SYNTAX AND EXAMPLESOF TUPLES 19 • Syntax: • a=(1,5,8,9) • B=(True , False , True) • Tuple Example:
  • 20.
    20 • Sets areused to store multiple items in a single variable. • A set is a collection which is unordered • Unordered means that the items in a set do not have a defined order. • Sets are unchangeable, meaning that we cannot change the items after the set has been created. • Sets are unindexed • Sets are written with curly brackets. SET IN PYTHON
  • 21.
    SYNTAX AND EXAMPLESOF SETS 21 Syntax: • a={“Apple” , “Orange” , “Banana” } Set Example:
  • 22.
    22 • Dictionaries areused to store data values in key:value pairs. • A dictionary is a collection which is ordered*, changeable and does not allow duplicates. • Dictionary holds a pair of values • Dictionary can also be created by the built-in function dict(). • An empty dictionary can be created by just placing to curly braces{}. DICTIONARIES IN PYTHON
  • 23.
    SYNTAX AND EXAMPLESOF DICTIONARIES 23 Syntax: • a={“keys “ :”values”, “keys “ :”values”} Dictionary Example:
  • 24.
    OPERATORS 24 • Operators areused to perform operations on values and variables in Python. • These are standard symbols used for the purpose of logical and arithmetic operations. • The value that the operator operates on is called the operand.
  • 25.
    TYPES OF ARITHMETICOPERATORS 25 • Arithmetic operators are used to perform mathematical operations like addition, subtraction, multiplication and division. There are 7 arithmetic operators in Python : 1. Addition 2. Subtraction 3. Multiplication 4. Division 5. Modulus 6. Exponentiation 7. Floor division
  • 26.
    26 1. Addition Operator: In Python, + is the addition operator. It is used to add 2 values. Example : ADDITION OPERATORS
  • 27.
    27 2 . SubtractionOperator : In Python, (– )is the subtraction operator. It is used to subtract the second value from the first value. Example : SUBTRACTION OPERATORS
  • 28.
    28 3. Multiplication Operator: In Python, * is the multiplication operator. It is used to find the product of 2 values. Example : MULTIPLICATION OPERATORS
  • 29.
    29 4. Division Operator: In Python, / is the division operator. It is used to find the quotient when first operand is divided by the second. Example : DIVISION OPERATOR
  • 30.
    30 • 5. ModulusOperator : In Python, % is the modulus operator. It is used to find the remainder when first operand is divided by the second. Example : MODULUS OPERATOR
  • 31.
    31 6.Exponentiation Operator :In Python, ** is the exponentiation operator. It is used to raise the first operand to power of second. Example : EXPONENTIATION OPERATOR
  • 32.
    32 • 7. Floordivision : In Python, // is used to conduct the floor division. It is used to find the floor of the quotient when first operand is divided by the second. Example : FLOOR DIVISION
  • 33.
    LOGICAL OPERATOR 33 • LogicalOperators in Python are used to perform logical operations on the values of variables. • The value is either true or false. We can figure out the conditions by the result of the truth values. • There are mainly three types of logical operators in python : logical AND, logical OR and logical NOT.
  • 34.
    34 Operator Description Example andReturns True if both statements are true x < 5 and x < 10 or Returns True if one of the statements is true x < 5 or x < 4 not Reverse the result, returns False if the result is true not(x < 5 and x < 10) TYPES OF LOGICAL OPERATORS
  • 35.
    CONDITIONAL STATEMENT https://www.careerera.com 35 Conditionalstatements are also called decision-making statements. We use those statements while we want to execute a block of code when the given condition is true or false. Type of condition statement in Python: If statement. If Else statement. Elif statement. Nested condition
  • 36.
  • 37.
    IF STATEMENT 37 • Ifstatement is most usually used as a conditional statement.
  • 38.
    IF ELSE STATEMENTIN PYTHON 38 • The if…else statement in Python is used for decision making. • The block of lines indented the same amount after the colon (:) will be executed whenever the condition is TRUE.
  • 39.
  • 40.
    ELIF STATEMENT 40 • Elifis a shortcut of else if condition statements. In Python one or more conditions are used in the elif statement For Example :
  • 41.
    41 • Nested ifstatements means an if statement inside another if statement. • When a program selects one of many paths, it can use nested or chained conditions. For Example: NESTED CONDITION
  • 42.
    42 • A loopis used for iterating over a sequence (that is either a list, a tuple, a dictionary, a set, or a string). • With the for loop we can execute a set of statements, once for each item in a list, tuple, set etc. For Example: LOOPS IN PYTHON
  • 43.
    INTRO​ TO FORLOOPS IN PYTHON​ 43 • A for loop is used for iterating over a sequence (that is either a list, a tuple, a dictionary, a set, or a string). • With the for loop we can execute a set of statements, once for each item in a list, tuple, set etc. For Example:
  • 44.
    PROGRAMS FOR LOOPS 44 •Loop program: • While loop program:
  • 45.
    45 • With thewhile loop we can execute a set of statements as long as a condition is true. For Example: WHILE LOOP IN PYTHON
  • 46.
    Basic Concepts ofObject-Oriented Programming In Python 46 • Object-Oriented Programming(OOP), is all about creating “objects”. • The concept of OOP in Python focuses on creating reusable code. • Major Python OOPs concept- • Class. • Object. • Inheritance. • Encapsulation.
  • 47.
    Class 47 • A classis a blueprint for the object. • It is a logical entity that has some specific attributes and methods. • The example for class of parrot can be : class Parrot: pass • The class keyword is use to define an empty class Parrot. • From class, we construct instances. An instance is a specific object created from a particular class.
  • 48.
    Object 48 • The objectis an entity that has state and behavior. • The object is an entity that has state and behavior. • When we define a class, it needs to create an object to allocate the memory. Class Definition Syntax: class ClassName: # Statement-1 . . . # Statement-N • Class Definition Syntax: class ClassName: # Statement-1 …… # Statement-N
  • 49.
    ENCAPSULATION 49 • we canrestrict access to methods and variables that prevents data from direct modification which is called encapsulation. • In encapsulation code and data are wrapped together within a single unit . • Encapsulation prevents your code from unauthorized user’s. • For example: Class Definition Syntax: class ClassName: # Statement-1 . . . # Statement-N
  • 50.
    INHERITANCE 50 • Inheritance isthe most important aspect of object-oriented programming, which simulates the real-world concept of inheritance. • It specifies that the child object acquires all the properties and behaviors of the parent object. • By using inheritance, we can create a class which uses all the properties and behavior of another class.
  • 51.
  • 52.
    FUNCTIONS 52 • A functionis a block of code which only runs when it is called. • The idea is to put some commonly or repeatedly done task together and make a function so that instead of writing the same code again and again for different inputs, we can call the function to reuse code contained in it over and over again.
  • 53.
    53 USES OF LENGTHFUNCTION Length : len() function is an inbuilt function in Python programming language that returns the length of the string. Syntax: len(string) For Example:
  • 54.
    54 • The filter()method constructs an iterator from elements of an iterable for which a function returns true. • Python's filter() is a built-in function. • The filter function takes in two arguments SYNTAX: filter(function, iterable) PROGRAM ON FILTER FUNCTION
  • 55.
    UNDERSTANDING LAMBDA FUNCTIONS 55 •A lambda function is a small, anonymous function that take any number of arguments but only have one expression. • We create them with the lambda keyword instead of the traditional def keyword.
  • 56.
    OVERVIEW OF MAPFUNCTIONS 56 • Map is a function that takes as an input a collection Example: • a list [‘BBA’,’MBA’,’BCA’], and a function e.g. upper(). • Then it will move every element of the collection through this function and produce a new collection with the same count of elements. SYNTAX: map(function, iterables)
  • 57.
    57 • The reduce()function, as the name describes, applies a given function to the iterables and returns a single value. • The reduce() function is defined in the functools module. • The reduce function can take in three arguments, two of which are required. reduce(function, iterable [, initializer]) SYNTAX: reduce(function, iterables) PROGRAM ON REDUCE FUNCTION
  • 58.
    EXPLORING COMMONLY USEDBUILT IN FUNCTIONS 58 • The min() function returns the item with the lowest value, or the item with the lowest value in an iterable. For Example:
  • 59.
    59 The max() functionreturns the item with the highest value, or the item with MAX FUNCTION IN PYTHON
  • 60.
    60 • The sort()method sorts the list ascending by default. For Example: SORT FUNCTION IN PYTHON
  • 61.
    PROGRAMS USING USERDEFINED FUNCTIONS 61 • A user-defined function (UDF) is a function provided by the user of a program or environment. For Example: Here sum is the user define function.
  • 62.
    Methods 62 • A methodin python is somewhat similar to a function, except it is associated with object/classes. • Method is called by its name, but it is associated to an object (dependent). • A method is implicitly passed the object on which it is invoked.
  • 63.
    63 • For example: PROGRAMSHOWING THE USE OF METHODS
  • 64.
    ARGUMENT’S 64 • An argumentis the value that are sent to the function when it is called. • Types of Arguments in Python Function Definition: 1.Default arguments :default arguments are values that are provided while defining functions. 2.Keyword arguments: Functions can also be called using keyword arguments , But all the keyword arguments should match the parameters in the function definition. 3.Positional arguments: During function call, values passed through arguments should be in the order of parameters in the function definition. This is called positional arguments.
  • 65.
    WORKING WITH FUNCTIONSWITH AND WITHOUT ARGUMENTS 65 Program without arguments:
  • 66.
  • 67.
    LOGIC FLOWCHARTS (Intuitive understandingof code flow) 67 • A flowchart typically shows the flow of data in a process, • It provides a pictorial representation of the algorithm detailing the steps more clearly , thus flow charts are easily understandable.
  • 68.
  • 69.
    PSEUDOCODE 69 • Pseudocode isa method of planning which enables the programmer to plan without considering about the syntax. • It has no syntax like any of the programming language and thus can’t be compiled or interpreted by the computer.
  • 70.
    LIST COMPREHENSION​ 70 • Listcomprehension offers a shorter syntax when you want to create a new list based on the values of an existing list. For Example:
  • 71.
    USE CASES VSLOOPS 71 • A use case is a methodology used in system analysis to identify, clarify and organize system requirements. • It also defines a list of steps that illustrate how a process will be carried out in a system. • While Loops in Python is used to iterate over a sequence (list, tuple, string) or other iterable objects. • Iterating over a sequence is called traversal.
  • 72.
    PRACTICE LIST COMPREHENSIONS 72 •List Comprehensions is a very powerful tool, which creates a new list based on another list, in a single, readable line.
  • 73.
    FUNCTIONS WITH RETURNITEMS 73 • A return statement is used to end the execution of the function call and “returns” the result (value of the expression following the return keyword) to the caller. The statements after the return statements are not executed. Syntax: def fun(): statements return [expression]
  • 74.
    Thank You !!! 74 (USA) 2-IndustrialPark Drive, E-Waldorf, MD, 20602, United States (USA) +1-844-889-4054 (Singapore) 3 Temasek Avenue, Singapore 039190 info@careerera.com www.careerera.com (INDIA) B-44, Sector-59, Noida Uttar Pradesh 201301 (INDIA) +91-92-5000-4000