1664611760basics-of-python-1
1664611760basics-of-python-1
CAREERERA
A warm welcome to Careerera family
®
CAREERERA
2
WHAT IS PYTHON
https://www.careerera.com 3
WHY PYTHON IS WIDELY USE?
• 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
4
DATA TYPES -NUMBERS
• 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
5
BOOLEAN
6
STRINGS DATATYPES
For Example:-
value = “Careerera”
7
CONCATENATION IN PYTHON
8
SUBSET IN PYTHON
9
USES OF POSITION
For Example:
Syntax:
list.index(element, start, end)
10
VARIABLES
11
BASIC PROGRAMMING SYNTAX
• 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 .
12
For example :
For example :
13
INTEGRATED DEVELOPMENT ENVIRONMENT(IDE) FOR PYTHON
14
DATA STRUCTURE
16
SYNTAX AND EXAMPLES OF LIST
Syntax:
Li=[] # empty list
Li1=[1,2,34,5] # list containing element’s
List Example:
17
TUPLE IN PYTHON
18
SYNTAX AND EXAMPLES OF TUPLES
• Syntax:
• a=(1,5,8,9)
• B=(True , False , True)
• Tuple Example:
19
SET IN PYTHON
20
SYNTAX AND EXAMPLES OF SETS
Syntax:
• a={“Apple” , “Orange” , “Banana” }
Set Example:
21
DICTIONARIES IN PYTHON
22
SYNTAX AND EXAMPLES OF DICTIONARIES
Syntax:
• a={“keys “ :”values”, “keys “ :”values”}
Dictionary Example:
23
OPERATORS
24
TYPES OF ARITHMETIC OPERATORS
• 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
25
ADDITION OPERATORS
1. Addition Operator : In Python, + is the addition
operator. It is used to add 2 values.
Example :
26
SUBTRACTION OPERATORS
27
MULTIPLICATION OPERATORS
28
DIVISION OPERATOR
29
MODULUS OPERATOR
30
EXPONENTIATION OPERATOR
31
FLOOR DIVISION
• 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 :
32
LOGICAL OPERATOR
• 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.
33
TYPES OF LOGICAL OPERATORS
34
CONDITIONAL STATEMENT
https://www.careerera.com 35
Syntax is:
if(condition):
36
IF STATEMENT
• If statement is most usually used as a conditional statement.
37
IF ELSE STATEMENT IN PYTHON
38
PROGRAMS FOR IF-ELSE
• If-else program:
39
ELIF STATEMENT
40
NESTED CONDITION
41
LOOPS IN PYTHON
42
INTROTO FOR LOOPS IN PYTHON
• 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:
43
PROGRAMS FOR LOOPS
• Loop program:
44
WHILE LOOP IN PYTHON
For Example:
45
Basic Concepts of Object-Oriented
Programming In Python
46
Class
Object
ENCAPSULATION
49
INHERITANCE
50
TYPES OF INHERITANCE
51
FUNCTIONS
52
USES OF LENGTH FUNCTION
53
PROGRAM ON FILTER FUNCTION
SYNTAX:
filter(function, iterable)
54
UNDERSTANDING LAMBDA FUNCTIONS
SYNTAX:
map(function, iterables)
56
PROGRAM ON REDUCE FUNCTION
• 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)
57
EXPLORING COMMONLY USED BUILT IN FUNCTIONS
• The min() function returns the item with the lowest value, or the
item with the lowest value in an iterable.
For Example:
58
MAX FUNCTION IN PYTHON
59
SORT FUNCTION IN PYTHON
60
PROGRAMS USING USER DEFINED FUNCTIONS
• 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.
61
Methods
62
PROGRAM SHOWING THE USE OF METHODS
• For example:
63
ARGUMENT’S
64
WORKING WITH FUNCTIONS WITH AND WITHOUT ARGUMENTS
65
PROGRAM WITH ARGUMENTS:
66
LOGIC FLOWCHARTS
(Intuitive understanding of code flow)
67
DIAGRAMATICAL REPRESENTATION OF A FLOW CHART
68
PSEUDOCODE
• 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.
69
LIST COMPREHENSION
• List comprehension offers a shorter syntax when you want to
create a new list based on the values of an existing list.
For Example:
70
USE CASES VS LOOPS
71
PRACTICE LIST COMPREHENSIONS
72
FUNCTIONS WITH RETURN ITEMS
def fun():
statements
return [expression]
73
Thank You !!!
(USA)
(INDIA)
2-Industrial Park Drive, E-Waldorf, MD,
20602, B-44, Sector-59, Noida
United States Uttar Pradesh 201301
(INDIA)
(USA) +91-92-5000-4000
+1-844-889-4054
(Singapore)
3 Temasek Avenue, Singapore 039190
[email protected]
www.careerera.com
74