30 Days
Data Scinece &
Analytics Master
Class
Day1 : Python for Data Science
Time: 6.00 PM IST
Free Registration
30 Days
Data Scinece &
Analytics Master
Class
Handbook
What is Master
Class ?
👍 This is the 30 Days Industrial Learning Activity.
👍 Its Online YouTube Live Class
👍 If you Invest 45 minutes daily, U will
become Master in Data Science
👍 You will get FREE E-Certificate
Webinar Participation
Certificate
“Learning is the beginning of wealth.
Searching & Learning is where the
miracle process all begins.”
Pantech?
[Link] Equipment Manufacturer
• IoT, AI, Robotics,Autonomous Robot
• Microprocessor/Microcontroller
• DSP,VLSI, Embedded System
• Power Electronics & Drives, Fuel Cell Trainer Kit
• Renewable Energy Lab, Electric Vehicle Lab
[Link] Training
[Link] Project
Our
Vision
Help 10 Million Students to
Learn the Technology in
Easy Way
Associate Partner for this
Master Class
[Link]
NANDHINI.S
Exp: 5 Yrs
Expert in
• Python Developer on Machine Learning
• Deep learning with computer vision
• Matlab – Image Processing
• Autonomous Car design using ROS with LIDAR
Language – Python , Java , HTML ,CSS.
Tools – ANACONDA NAVIGATOR, JUPYTER
NOTEBOOK,
• GOOGLE COLAB.
Graduation : BE – ECE | 2011
What U will Learn from 30
Days Data Science &
Analytics Master Class
Data Science & Analytics
Learning Plan
01 02 03 04 05
Python
Library
Pandas
Analytics
Tools Industry Project
Numpy Distribution
Introduction To MatplotLib Visualization PowerBi Project Building,
Python and Python Cborn, SKLearn Tableo DSA Jobs
Data Structures Lib Aggregation
Collab Statistics
Day wise Learning Plan
Day -1 : Python for Data
Science (5 Solved end-to-end Data Science Projects in Python)
Day -2: Advanced Python Programming
Day -3: Pandas Library – Introduction
Day -4: Pandas Library – Data Structures
Day -5: Numpy library – Array Operations | Mathematical
Functions
Day -6: Numpy – Sort, Search and Counting Functions
Day -7: Matplotlib , Histogram Using Matplotlib | I/O With
Numpy
Day -8: Matplotlib Library – Introduction , Pyplot API | Types Of
Plots
Day -9: Seaborn Library
Day -10: SKLearn Library
Day -11: Google Colab Notebook
Day -12: Python – Date and Time, Data Wrangling
Day -13: Python – Data Aggregation
Day -14: Python – Word Tokenization , Stemming and
Lammetization
Day -15: Python – Data Visualization
Day wise Learning Plan
Day -16: Python – Statistical Analysis
Day -17: Python – Types Of Distribution
Day -18: Python – Correlation ,Chi-Square Test , Linear Regression
Day -19: Tableau – Introduction and Tools
Day -20: Tableau – Data Sources , Worksheets
Day -21: Spatial Data Science For Covid-19 Disease Prediction
Day -22: Power-BI – Introduction, Installation Steps and Architecture
Day -23: Power-BI – Data Modelling , Visualization Options | Excel Integration
Day -24: Parkinson’s Disease Prediction – XG Boost Classifier
Day -25: House Price Prediction using Random Forest Regression
Day -26: Customer Segmentation Using ML – K-Means Clustering
Day -27: Home Loan Prediction using Decision Tree Classifier
Day -28: Spam Classification using NLP
Day -29: Hand Written Digit Recognition Using CNN
Day -30: Churn Prediction using Deep Learning
List of Projects for Demo in YouTube Live
1. Spatial Data Science For Covid-19 Disease Prediction
2. Parkinson’s Disease Prediction-XGBoost Classifier
3. House Price Prediction-Random Forest Regression
4. Customer Segmentation Using ML-K-Means Clustering
5. Home Loan Prediction-Decision Tree Classifier
6. Spam Classification-NLP
7. Hand Written Digit Recognition Using Python-CNN
8. Churn Prediction-Deep Learning
9. Crop Yield Prediction
[Link] water level prediction
All Projects in Jupyter Notebook
What you will get from this Free 30 Days
Master Class?
1. You can attend YouTube Live Class
2. Free E-Certificate ( WEBINAR
PARTICIPATION CERTIFICATE)
How to mark your
Attendance in YouTube
Live
Ans :
Class?
During the Live Class, organizer will post Google Form link
in Live Chat. The Participants should submit the from on daily
basis.
Minimum 25 Days Attendance is Required to get Free Master Class
Participation Certificate.
The Link will be available during the Live.
Note :
From the LIVE Class date, the live video will get
removed from the YouTube in 3 days.
Sample Webinar Participation Certificate?
On Demand
You can get chance to apply 1 Month
Internship on Data Science & Analytics
Master Class
[Link]
[Link]/dat
a-science-master-cl
ass/
What is
Internship???
?
Learn
Practice
Verify
Get Certified
Grow
Free Master Class DSA 1 Month Internship on DSA
Master Class Participation Internship Completion Certificate
Certificate
Minimum 25 Class should attend Recorded Class Link will be provided. – LMS Portal
YouTube Live Access
YouTube Live Mandatory Your Choice. You can attend Live or else You can
watch Recorded Class in LMS Portal
All Projects Demo class in Step by Step Video Explanation Content in LMS
YouTube Live Portal
Access : 3 Days VIP WhatsApp Group Support
You Can Download All PPTs
4 Nos of Hackathon Class in Zoom Live. The
Recording also will be provided
You Can Download All Project Files
Mentor will guide you to finish 10 Projects
Access : 60 Days
Objective of this 30 Days Master Class
Pantech will make you to
Create 10 Projects in
Data Science & Analytics
in 30 Days
1 Month Internship in Data Science
[Link] E-Certificate(30Days Internship on Data
Science Engineering)
[Link] organized Video content
[Link] All Files
[Link] PPTs
[Link]
[Link] Time.
[Link] Period: 60Days from the date of payment
What You Will
• 30 Days Learning Activity
Get??? Complete
Project Files
• Data Science Core Concepts
• 10 + Projects Project PPT
1. Spatial Data Science For Covid-19 Disease Prediction
2. Parkinson’s Disease Prediction-XGBoost Classifier
3. House Price Prediction-Random Forest Regression
4. Customer Segmentation Using ML-K-Means Clustering Video Class Access for
5. Home Loan Prediction-Decision Tree Classifier 2 Months
6. Spam Classification-NLP
7. Hand Written Digit Recognition Using Python-CNN
8. Churn Prediction-Deep Learning
9. Crop Yield Prediction
[Link] water level prediction
Get chance to Enroll 1-
Month Internship on
demand
How to join in 1 month Internship
[Link]
Click
Here
Coupon Code:
WELCOMEDSE
DATA SCIENCE
What is Data Science?
Data science is an interdisciplinary field that uses scientific methods,
processes, algorithms and systems to extract knowledge and insights from
data, and apply knowledge from data across a broad range of application
domains.
Python
Introduction
Python is :
1. High-level programming language.
2. Fast to learn and fast to develop application.
3. Available for many platforms.
4. Implement complex logic with very few lines of code.
History
Guido van Rossum
• At National Research Institute for Mathematics and
Computer Science in Netherland.
Why One Should use PYTHON ?
What can I do in PYTHON
WHY ?
Data Processing
Signal Processing
Pygame
Maya Python
Music Software
Web site development frame work
PYTHON 2 VS. PYTHON 3
1. Python 2 is legacy, Python 3 is the present and future.
2. Python 3 was released in 2008.
3. Python 3 don’t have enough libraries.
4. That’s why python 2 is present and still ON.
Python – Interactive Mode Programming:
Type the following text at the Python Prompt:
print ("Hello, Python!”)
If we run this code , we will get the following code:
Hello , Python!
Python – Identifiers
A python identifier is a name used to identify a variable , function , class ,
module or any object.
An identifier starts with a letter A to Z or a to z or an underscore followed
by zero or more letters, underscores and digits(0-9).
Python does not allow punctuation characters like @, $, and % within
identifiers.
It is a case sensitive programming language.
Python – Identifiers
Following are some of the naming conventions for Python identifiers:
Class names start with an uppercase letter.
All other identifiers start with a lowercase letter.
If an identifier starts with a single leading underscore , it indicates that the identifier is
private.
If an identifier starts with two leading underscores , it indicates a strongly private
identifier.
If the identifier ends with two trailing underscores , the identifier is a language – defined
special name.
Reserved Words:
The following list shows a list of reserved keywords.
And
Assert
Break
Class
Continue
Def
Del
exec
Lines and Indentation:
Python provides no braces to indicate blocks of code for class and function
definitions or flow control.
The number of spaces in the indentation is variable , but all the statements
within the block must be indented by the same amount.
if True:
print "True"
else:
print "False"
Quotation in Python
Python accepts single(‘) , double(“) and triple(“’ or ‘’’’’’) quotes to denote
string literals , as long as the same type of quote starts and ends the string.
Triple quotes are used to span the string across multiple lines.
word = 'word'
sentence = "This is a sentence."
paragraph = """This is a paragraph. It is
made up of multiple lines and sentences."""
Comments In Python
A hash sign(#) that is not inside a string literal begins a comment.
All characters after the # and up to the end of the physical line are part of
the comment .
Python interpreter ignores them.
#!/usr/bin/python
# First comment
print ("Hello, Python!“) # second comment
Comments In Python
Output:
Hello , Python!
Python – Variable Types
Variables are nothing but reserved memory locations to store values.
When we create a variable , we reserve some space in memory.
Based on the data type of a variable , the interpreter allocates memory and
what can be stored in the reserved memory.
If we assign different data types to variables , we can store integers ,
decimals or characters in these variables.
Python – Variable Types
Assigning Values to Variables:
#!/usr/bin/python
counter = 100 # An integer assignment
miles = 1000.0 # A floating point
name = "John" # A string
print counter
print miles
print name
Python – Variable Types
Here , 100 , 1000 and “John” are the values assigned to counter , miles and
name variables .
Output:
100
1000.0
John
Python – Variable Types
Multiple Assignment:
It allows us to assign a single value to several variables.
a=b=c=1.
An integer object is created with a value 1 and all three variables are
assigned to the same memory location.
Multiple objects can also be assigned to multiple variables.
Python – Variable Types
Eg,
a,b,c = 1,2,’john”
Two integer objects with values 1 and 2 are assigned to variables a and b
respectively.
One string object with the value “john” is assigned to the variable c.
Python – Variable Types
Standard Data Types:
The data stored in the memory can be of many types.
A person’s age is stored as a numeric value and his address is stored as
alphanumeric characters.
Python has 5 standard data types:
Python – Variable Types
Numbers
String
List
Tuple
Dictionary
Python – Variable Types
Python Numbers:
Number data types store numeric values.
Number objects are created when we assign a value to them.
Var1 = 1
Var2 = 10
Python – Variable Types
We can also delete a reference to the number object using the del statement.
del var1[,var2[,var3[....,varN]]]]
We can delete a single object or multiple objects using the del statement.
del var
del var_a, var_b
Python – Variable Types
Python supports four different numerical types:
Int(signed numbers)
Long(long integers , they also can be represented in octal and
hexadecimal).
Float(floating point real values).
Complex(complex numbers).
Python – Variable Types
Python - Strings:
Strings in python are identified as a contiguous set of characters represented in
quotation marks.
Subsets of strings can be taken using the slice operator([] and [:]) with indexes
starting at 0 in the beginning of the string .
They work their way from -1 to the end.
The plus (+) sign is the string concatenation operator , asterick(*) is the
repetition operator.
Python – Variable Types
#!/usr/bin/python
str = 'Hello World!'
print (str) # Prints complete string
print (str[0]) # Prints first character of the string
print (str[2:5]) # Prints characters starting from 3rd to 5th print str[2:] # Prints
string starting from 3rd character
print (str * 2) # Prints string two times
print (str + "TEST“) # Prints concatenated string
Python – Variable Types
Hello World!
H
llo
llo World!
Hello World!Hello World!
Hello World!TEST
Python – Variable Types
Python Lists:
Sequence is the most basic data structure in python.
Each element of a sequence is assigned a number – its position or index.
The most common python sequences are lists and tuples.
Several operations can be performed in a sequence like indexing , slicing ,
adding and multiplying.
Python - Lists
A list is nothing but a collection of comma separated values between square brackets.
The items in a list need not be of the same type.
list1 = ['physics', 'chemistry', 1997, 2000];
list2 = [1, 2, 3, 4, 5 ];
list3 = ["a", "b", "c", "d"]
List indices start at 0 .
Lists can be sliced , concatenated and so on.
Python - Lists
Accessing Values In Lists:
To access values in lists , use the square brackets for slicing along with the index to obtain
the value available at that index.
#!/usr/bin/python
list1 = ['physics', 'chemistry', 1997, 2000];
list2 = [1, 2, 3, 4, 5, 6, 7 ];
print ("list1[0]: ", list1[0])
print ("list2[1:5]: ", list2[1:5])
Output:
list1[0]: physics
list2[1:5]: [2, 3, 4, 5]
Updating Lists:
We can update single or multiple elements of the lists by giving the slice
on the left – hand side of the assignment operator.
We can add to elements in the list with the append() method.
Updating Lists:
#!/usr/bin/python
list = ['physics', 'chemistry', 1997, 2000];
print ("Value available at index 2 : " )
print (list[2])
list[2] = 2001;
print ("New value available at index 2 : " )
print (list[2])
Output:
Value available at index 2 :
1997
New value available at index 2 :
2001
Delete List Elements:
To remove a list element , we can use either the del statement if we know which
elements we are deleting or the remove() method if we do not know.
#!/usr/bin/python
list1 = ['physics', 'chemistry', 1997, 2000];
print (list1)
del list1[2];
print ("After deleting value at index 2 : “)
print (list1)
Output:
['physics', 'chemistry', 1997, 2000]
After deleting value at index 2 :
['physics', 'chemistry', 2000]
Basic List Operations:
Indexing ,Slicing and Matrixes:
Lists are sequences , indexing and slicing work the same way for lists as
they do for strings.
L = ['spam', 'Spam', 'SPAM!']
Python Tuples
A tuple is another sequence data type that is similar to the list.
A tuple consists of a number of values separated by comma.
Tuples are enclosed within parentheses.
Lists are enclosed in [] , their elements and size can be changed.
Tuples are enclosed within (()) and cannot be updated.
Python - Tuples
#!/usr/bin/python
tuple = ( 'abcd', 786 , 2.23, 'john', 70.2 )
tinytuple = (123, 'john')
print(tuple) # Prints the complete tuple
Print(tuple[0]) # Prints first element of the tuple
print(tuple[1:3]) # Prints elements of the tuple starting from 2nd till 3rd print
tuple([2:]) # Prints elements of the tuple starting from 3rd element
print(tinytuple * 2) # Prints the contents of the tuple twice
Print(tuple + tinytuple) # Prints concatenated tuples
Output:
('abcd', 786, 2.23, 'john', 70.2)
abcd
(786, 2.23)
(2.23, 'john', 70.2)
(123, 'john', 123, 'john')
('abcd', 786, 2.23, 'john', 70.2, 123, 'john')
Python - Dictionary
Python – dictionaries work like associative arrays and consist of key –
value pairs.
A dictionary key can be of any type but they are usually of the type
numbers or Strings.
Values can be any arbitrary python object.
Dictionaries are enclosed by curly braces({}) .
The values can be assigned and accessed using square braces([]).
Dictionary - Example
#!/usr/bin/python
dict = {}
dict['one'] = "This is one"
dict[2] = "This is two"
tinydict = {'name': 'john','code':6734, 'dept': 'sales'}
Dictionary - Example
print(dict['one']) # Prints value for 'one' key
print(dict[2]) # Prints value for 2 key
Print(tinydict) # Prints complete dictionary
print([Link]()) # Prints all the keys
Print([Link]()) # Prints all the values
Output:
This is one
This is two
{'dept': 'sales', 'code': 6734, 'name': 'john'}
['dept', 'code', 'name']
['sales', 6734, 'john']
Python – Basic Operators:
Python supports the following operators:
Arithmetic Operators
Comparison operators
Logical Operators
Python – Arithmetic Operators
+ Addition – Adds values on either side of the operator.
Eg, a+b = 30.
- Subtraction – Subtracts right hand operand from left hand operand.
Eg, a-b = -10
* Multiplication – Multiplies values on either side of the operator.
Eg, a*b = 200
Python – Comparison Operators
These operators compare the values on either sides of them and decide the
relation among them.
They are also called relational operators.
Assume a = 10 and b = 20
Python – Comparison Operators
== : If the values of two operands are equal , then the condition becomes
true.
(a==b) is not true.
!=: If the values of two operands are not equal , then the condition
becomes true.
(a!=b) is true.
Python – Comparison Operators
>: If the value of left operand is greater than the value of right operand ,
then the condition becomes true.
(a>b) is not true.
Python – Logical Operators
a = 10, b = 20
Logical AND: If both the operands are true , then the condition becomes true.
(a and b) is true
Logical OR: If any of the two operands are non-zero , then the condition
becomes true.
(a or b) is true.
Python – Logical Operators
Logical NOT: Used to reverse the logical state of its operand.
Not(a and b) is false.
Python – Decision Making
Decision making is an anticipation of conditions occuring while execution
of the program.
Decision structures evaluate multiple expressions which produce TRUE or
FALSE as outcome.
Python – Decision Making
Python – Decision Making
Python programming language assumes non-zero values as true and the
zero values as false.
There are three different types of decision making statements:
If statements:
An if statement consists of a boolean expression followed by one or more
statements.
Python – Decision Making
If…else statements:
An if statement can be followed by an optional else statement , which
executes when the boolean expression is false.
Nested if statements:
We can use one if or else if statement inside another if or else if statements
Example - If
#!/usr/bin/python
var = 100
if ( var == 100 ) : print ("Value of expression is 100”)
print ("Good bye!”)
Output:
Value of expression is 100
Good bye!
Python - Loops
Statements are executed sequentially.
The first statement in a function is executed first , followed by the second
and so on.
Programming languages provide various control structures that allow for
more complicated execution paths.
Python - Loops
Python - Loops
While loop:
Repeats a statement or a group of statements till the condition is true.
It tests the condition before executing the loop body.
For loop:
Executes a sequence of statements multiple times and abbreviates the code that manages the loop
variable.
Nested loop:
We can use one or more loop inside any another while , for or do.. While loop.
Loop Control Statement:
Loop Control Statements change execution from its normal sequence.
Following are the different types of loop control statements.
Break statement:
Terminates the loop statement and transfers execution to the statement immediately
following the loop.
Continue statement:
Causes the loop to skip the remainder of the body and immediately retest its condition
prior to reiterating.
Loop Control Statement:
Pass statement:
The pass statement is used when a statement is required syntactically but
we do not want any command or code to execute.
Python - 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.
Var1 = 1
Var2 = 10
Python - Numbers
We can also delete single object or multiple object using the del statement.
del (var)
del (var_a, var_b)
Python - Strings
Strings are the most popular types in python.
It can be created by enclosing characters in quotes.
Var1 = ‘Hello World’
Var2 = ‘Python Programming’
Python - Strings
Accessing Values in Strings:
Python does not support a character type.
They are treated as strings of length 1 , thus they are also considered a
substring.
To access substrings , square brackets are used for slicing along with the
index or indices to obtain the substring.
Python - Strings
Accessing Values in Strings:
#!/usr/bin/python
var1 = 'Hello World!'
var2 = "Python Programming"
print ("var1[0]: ", var1[0])
print ("var2[1:5]: ", var2[1:5])
Output:
var1[0]: H
var2[1:5]: ytho
Python - Strings
Updating Strings:
We can “update” an existing string by reassigning a variable to another string.
The new value can be related to the previous value or to a completely different
string.
Eg:
#!/usr/bin/python
var1 = 'Hello World!'
print ("Updated String :- ", var1[:6] + 'Python’)
Output:
Updated String :- Hello Python
String Formatting Operator
One of the main features of python is the string formatting operator , %.
#!/usr/bin/python
print ("My name is %s and weight is %d kg!" % ('Zara', 21))
Python - Lists
A list is nothing but a list of comma separated values(items) between
square brackets.
The items in a list need not be of the same data type.
list1 = ['physics', 'chemistry', 1997, 2000];
list2 = [1, 2, 3, 4, 5 ];
list3 = ["a", "b", "c", "d"]
Python - Lists
Accessing Values in Lists:
To access values in lists , use the square brackets for slicing along with the index or indices
to obtain value at that index.
#!/usr/bin/python
list1 = ['physics', 'chemistry', 1997, 2000];
list2 = [1, 2, 3, 4, 5, 6, 7 ];
print "list1[0]: ", list1[0]
print "list2[1:5]: ", list2[1:5]
Output:
list1[0]: physics
list2[1:5]: [2, 3, 4, 5]
Python - Lists
Updating Lists:
We can update single or multiple elements of lists by giving the slice on
the left – hand side of the assignment operator .
We can add to elements in the list with the append() method.
Python - Lists
Updating Lists:
#!/usr/bin/python
list = ['physics', 'chemistry', 1997, 2000];
print ("Value available at index 2 : “)
print (list[2])
list[2] = 2001;
print ("New value available at index 2 : " )
print (list[2])
Output:
Value available at index 2 :
1997
New value available at index 2 :
2001
Python - Lists
Delete List Elements:
To remove an element from the list , we can use either the del statement if
we know exactly which elelments we are deleting or the remove method if
we do not know.
Python - Lists
#!/usr/bin/python
list1 = ['physics', 'chemistry', 1997, 2000];
print (list1)
del (list1[2]);
print ("After deleting value at index 2 : “)
print (list)
Output:
['physics', 'chemistry', 1997, 2000]
After deleting value at index 2 :
['physics', 'chemistry', 2000]
Basic List Operations:
Lists respond to the “+” and “*” operators like strings.
Python - Lists
Indexing , Slicing and Matrixes:
L = ['spam', 'Spam', 'SPAM!']
Python - Tuples
A tuple is a collection of objects which ordered and immutable.
Tuples are sequences , like lists.
The difference between lists and tuples is that tuples cannot be changed unlike lists
and tuples use parentheses , whereas a list use square brackets.
tup1 = ('physics', 'chemistry', 1997, 2000);
tup2 = (1, 2, 3, 4, 5 );
up3 = "a", "b", "c", "d";
Python - Tuples
This is an example of empty tuple:
tup1 = ();
Accessing Values in Tuples:
To access the values in a tuple , use the square brackets for slicing along
with the index to obtain the value available at that index.
Python - Tuples
Accessing Values in Tuples:
#!/usr/bin/python
tup1 = ('physics', 'chemistry', 1997, 2000);
tup2 = (1, 2, 3, 4, 5, 6, 7 );
print ("tup1[0]: ", tup1[0]);
print ("tup2[1:5]: ", tup2[1:5]);
Output:
tup1[0]: physics
tup2[1:5]: [2, 3, 4, 5]
Updating Tuples:
Tuples are immutable which means we cannot change or update the values of tuple elements.
#!/usr/bin/python
tup1 = (12, 34.56);
tup2 = ('abc', 'xyz');
# Following action is not valid for tuples
# tup1[0] = 100;
# So let's create a new tuple as follows
tup3 = tup1 + tup2;
print (tup3);
Output:
(12, 34.56, 'abc', 'xyz')
Delete Tuple Elements:
To explicitly remove an entire tuple , use the del statement.
#!/usr/bin/python
tup = ('physics', 'chemistry', 1997, 2000);
print tup;
del tup;
print "After deleting tup : ";
print tup;
Output:
('physics', 'chemistry', 1997, 2000)
After deleting tup :
Traceback (most recent call last):
File "[Link]", line 9, in <module>
print tup;
NameError: name 'tup' is not defined
Python - Dictionary
Each key is separated from the value by a colon, the items are separated by
commas and the whole thing is enclosed within curly braces.{}.
Accessing Values In Dictionary:
#!/usr/bin/python
dict = {'Name': 'Zara', 'Age': 7, 'Class': 'First'}
print ("dict['Name']: ", dict['Name'])
print ("dict['Age']: ", dict['Age'])
Output
dict['Name']: Zara
dict['Age']: 7
Updating Dictionary:
We can update a dictionary by adding a new entry or a new key-value pair.
#!/usr/bin/python
dict = {'Name': 'Zara', 'Age': 7, 'Class': 'First'}
dict['Age'] = 8; # update existing entry
dict['School'] = "DPS School"; # Add new entry
print "dict['Age']: ", dict['Age']
print "dict['School']: ", dict['School']
Output:
dict['Age']: 8
dict['School']: DPS School
Delete Dictionary Elements:
We can either remove individual dictionary elements or clear the entire
contents of the dictionary.
We can also delete a entire dictionary in a single operation.
Delete Dictionary Elements:
#!/usr/bin/python
dict = {'Name': 'Zara', 'Age': 7, 'Class': 'First'}
del dict['Name']; # remove entry with key 'Name'
[Link](); # remove all entries in dict
del dict ; # delete entire dictionary
print "dict['Age']: ", dict['Age']
print "dict['School']: ", dict['School']
Output:
dict['Age']:
Traceback (most recent call last):
File "[Link]", line 8, in <module>
print "dict['Age']: ", dict['Age'];
TypeError: 'type' object is unsubscriptable
Properties Of Dictionary Keys
More then one entry per key is not allowed.
No duplicate key is allowed.
When duplicate keys are encountered during assignment , the last assignment
wins.
#!/usr/bin/python
dict = {'Name': 'Zara', 'Age': 7, 'Name': 'Manni'}
print "dict['Name']: ", dict['Name']
Output:
dict['Name']: Manni
Properties Of Dictionary Keys
Keys must be immutable.
It means we can use strings , numbers or tuples as dictionary keys but
something like[‘key’] is not allowed.
#!/usr/bin/python
◦ dict = {['Name']: 'Zara', 'Age': 7}
◦ print ("dict['Name']: ", dict['Name'])
Output:
Traceback (most recent call last):
File "[Link]", line 3, in <module>
dict = {['Name']: 'Zara', 'Age': 7};
TypeError: unhashable type: 'list'
Python - Functions
A function is a block of organized , reusable code that is used to perform a
related action.
Functions provide better modularity and code reusability.
Defining a Function
Function blocks begin with the def keyword followed by the function name and parentheses(()).
Any input parameters should be placed within these parentheses.
Syntax:
def functionname( parameters ):
"function_docstring"
function_suite
return [expression]
Example:
def printme( str ):
"This prints a passed string into this function"
print (str)
return
Calling a Function
Defining a function only gives it a name, specifies the parameters that are
to be included in the function and structures the blocks of code.
Calling a Function
#!/usr/bin/python
# Function definition is here
def printme( str ):
"This prints a passed string into this function"
print str
return;
# Now you can call printme function
printme("I'm first call to user defined function!")
printme("Again second call to the same function")
Output:
I'm first call to user defined function!
Again second call to the same function
Pass By Reference Vs Value
All the parameters in python language are passed by reference.
If you change what a parameter refers to within a function , the change
also reflects back in the calling function.
Example:
#!/usr/bin/python
# Function definition is here
def changeme( mylist ):
"This changes a passed list into this function"
[Link]([1,2,3,4]);
print "Values inside the function: ", mylist
return
# Now you can call changeme function
mylist = [10,20,30];
changeme( mylist );
print "Values outside the function: ", mylist
Output:
Values inside the function: [10, 20, 30, [1, 2, 3, 4]]
Values outside the function: [10, 20, 30, [1, 2, 3, 4]]
Pass By Reference (Example 2):
#!/usr/bin/python
# Function definition is here
def changeme( mylist ):
"This changes a passed list into this function"
mylist = [1,2,3,4]; # This would assig new reference in mylist
print "Values inside the function: ", mylist
return
Pass By Reference (Example 2):
# Now you can call changeme function
mylist = [10,20,30];
changeme( mylist );
print "Values outside the function: ", mylist
Output:
Values inside the function: [1, 2, 3, 4]
Values outside the function: [10, 20, 30]
Function Arguments
Required arguments
Keyword arguments
Default arguments
Variable – length arguments
Function Arguments
Required Arguments:
They are the arguments passed to a function in correct positional order.
The number of arguments in the function call should exactly match with
the function definition.
Function Arguments
#!/usr/bin/python
# Function definition is here
def printme( str ):
"This prints a passed string into this function"
print str
return;
# Now you can call printme function
printme()
Output:
Traceback (most recent call last):
File "[Link]", line 11, in <module>
printme();
TypeError: printme() takes exactly 1 argument (0 given)
Function Arguments
Keyword Arguments:
They are related to the function calls.
When we use keyword arguments in a function call , the caller identifies
the arguments by the parameter name.
Function Arguments
Keyword Arguments:
#!/usr/bin/python
# Function definition is here
def printme( str ):
"This prints a passed string into this function"
print str
return;
# Now you can call printme function
printme( str = "My string")
Function Arguments
Output:
My string
Function Arguments
Keyword Arguments:
#!/usr/bin/python
# Function definition is here
def printinfo( name, age ):
"This prints a passed info into this function"
print "Name: ", name
print "Age ", age
return;
# Now you can call printinfo function
printinfo( age=50, name="miki" )
Function Arguments
Output:
Name: miki
Age 50
Function Arguments
Default Arguments:
A default argument is an argument that assumes a default value if the value
is not provided in the function call for that argument.
Function Arguments
#!/usr/bin/python
# Function definition is here
def printinfo( name, age = 35 ):
"This prints a passed info into this function"
print "Name: ", name
print "Age ", age
return;
# Now you can call printinfo function
printinfo( age=50, name="miki" )
printinfo( name="miki" )
Output:
Name: miki
Age 50
Name: miki
Age 35
Variable Length Arguments
#!/usr/bin/python
# Function definition is here
def printinfo( arg1, *vartuple ):
"This prints a variable passed arguments"
print "Output is: "
print arg1
for var in vartuple:
print var
return;
# Now you can call printinfo function
printinfo( 10 )
printinfo( 70, 60, 50 )
Output:
Output is:
10
Output is:
70
60
50
The Return Statement
The statement return exits a function , optionally passing back an
expression to the caller.
Example:
#!/usr/bin/python
# Function definition is here
def sum( arg1, arg2 ):
# Add both the parameters and return them."
total = arg1 + arg2
print "Inside the function : ", total
return total;
# Now you can call sum function
total = sum( 10, 20 );
print "Outside the function : ", total
Output:
Inside the function : 30
Outside the function : 30
Global Vs Local Variables:
Variables that are defined inside a function body have local scope and
those defined outside have a global scope.
Local variables can be accessed only inside the function in which they are
declared , whereas global variables can be accessed throughout the
program body by all functions.
Example:
#!/usr/bin/python
total = 0; # This is global variable.
# Function definition is here
def sum( arg1, arg2 ):
# Add both the parameters and return them."
total = arg1 + arg2; # Here total is local variable.
print "Inside the function local total : ", total
return total;
# Now you can call sum function
sum( 10, 20 );
print "Outside the function global total : ", total
Output:
Inside the function local total : 30
Outside the function global total : 0
Follow us on:
Instagram--[Link]
Telegram--[Link]
YouTube--[Link]
Podcasts--[Link]
After Internship Registration what you have to
do?
[Link] to [Link]
[Link] the Video on daily basis for next 30 Days.
Practice the Concept and submit assignments
[Link] your doubts in VIP Group. Group link is avail in your
dashboard.
[Link] all the videos and download your Certificate from
your dashboard
Internship Certificate (Sample)
Projects
Included in
Internship.
Pantech will make you to Create 10 Projects in
Data Science Engineering in 30 Days
30 Days Internship on Machine Learning Master
Class
Reg Link: [Link]
Discount Coupon Code: WELCOMEML
Happy
learning
Call / whatsapp : +91
9840974408
THANK
S
Further Information:
Senthil Kumar – 98409 74406
Srinivasan – 7010888841
Kumarasamy - 8925533489
[Link] |
CREDITS: This presentation template was created by
Slidesgo, including icons by Flaticon, and infographics &
training@[Link]
images by Freepik