This document provides an outline and overview of a presentation on learning Python for beginners. The presentation covers what Python is, why it is useful, how to install it and common editors used. It then discusses Python variables, data types, operators, strings, lists, tuples, dictionaries, conditional statements, looping statements and real-world applications. Examples are provided throughout to demonstrate key Python concepts and how to implement various features like functions, methods and control flow. The goal is to give attendees an introduction to the Python language syntax and capabilities.
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
Basic of Python- Hands on Session
1. Online Presentation on
Learn Python: Python for
beginners
Presented by
Prof. DharmeshTank
CE / IT Department
09-May-2020
2. Outline
What and Why Python?
Installation of Python
Editors used for Python
Variable declaration, Numbers & Data types
Operators, String, List,Tuples, Dictionary
Conditional Statements
Looping Statements
Application of Python language
Conclusion
3. What is
Python?
Python is an interpreted, object-
oriented, high-level programming
language with dynamic semantics.
Source: https://www.python.org/
4. Why Python?
It is portable, expandable, and embeddable.
It can easily managing and organizing complex data.
It’s syntax are clean.
Python is the language of choice for the Machine Learning,
AI, Data Science, Raspberry Pi.
Python offers tools that streamline the IoT development
process, such as webrepl.
Since Python is an interpreted language, you can easily
test your solution without compiling the code or flashing
the device.
7. EditorsUsed
for Python
Python IDLE
SublimeText
Atom
Jupiter
PyDev
Anaconda
PyCharm
Spyder
Visual Studio IDE
Vi /Vim (Used in Linux)
Thonny (Used in Linux)
Source: www.datacamp.com%2Fcommunity%2Ftutorials%2Ftop-python-ides-for-2019&psig=AOvVaw0bp2ioDTCGM
8. Variable
declaration &
Data types
• What are the different data types in Python ?
In Python, data types are broadly classified into the
following:
1. Numbers
2. List
3.Tuple
4. Strings
5. Dictionary
• How to define a variable?
Syntax: VariableName = value
Example: phoneNo = 12345
Marks = 85.45
• How to comments?
Syntax: #variableName = value
Example: >>> # a=10
9. Operators
1. Assignment Operator (‘=‘)
2. Arithmetic Operators
Multiplication (‘*’)
Division (‘/‘)
Addition (‘+’)
Subtraction (‘-‘)
Modulo (‘%’)
3. Relational or Comparison Operators
Equal to (‘==‘) , Greater than (‘>’), Lesser than (‘<‘) ,
Greater than or equal to (‘>=’) , Lesser than or equal to
(‘<=‘), Not equal to (!=)
4. Logical Operators
and -> Example: ((5 > 3) and (3 < 5)) True
or -> Example: ((5 < 3) or (3 < 5)) True
not -> Example: not (5<3) returnsTrue (reverse of
False).
11. String
How to define a string ?
Syntax :
stringName = “string”or stringName = ‘string’
Example:
programmingLanguage = “Python”
or
programmingLanguage = ‘Python’
The starting index of any string is zero.
15. List
A list is a container that holds many objects under a
single name.
Syntax : listName = [object1, object2, object3]
Example: fruit = [‘Apple', ‘Mango', ‘Orange’]
It is same as array in C, C++ or JAVA.
To access the list :
Example : fruit[0] = Apple, fruit[1] = Mango,
fruit[2] = Orange
16. ListOperations
append() - To append any value in list
Syntax : list.append(element)
insert() - To Insert at specific place in list
Syntax : list.insert(index, element)
remove() - To remove the element from list
Syntax: list.remove(element)
sort -To sort the list in ascending order
Syntax: list.sort()
reverse -To reverse the list
Syntax: list.reverse()
pop -To delete the specific index value
Syntax: list.pop(index)
18. Tuples
• A tuple is a container that holds many objects under a single
name.
• A tuple is immutable which means, a tuple once defined
cannot be modified.
Syntax : tupleName = (object1, object2, object3)
Example: ImpDate = (“11-09-1989”, “13-2-2020”)
• To access the values in a tuple
>>> ImpDate[1]
>>>13-2-2020
• To delete a tuple
Syntax: del(tupleName)
Example: del(ImpDate)
19. Dictionary
• A dictionary is a set of key-value pairs referenced by a
single name.
Syntax : dictionaryName = {“keyOne” : “valueOne”,
“keyTwo”: “valueTwo”}
Example:>>> colorOfFruits = {“apple”: “red”,
“mango”: “yellow”, “orange”: “orange”}
• To Retrieve the value of dictionary
Syntax: dictionaryName[“key”]
Example: >>>colorOfFruits[“mango”]
>>>yellow
20. Dictionary
inbuilt
Functions
List all keys : keys() is used to list all the keys in a dictionary.
Syntax: dictionaryName.keys()
List all values : values() is used to list all the values in a dictionary
Syntax: dictionaryName.values()
Delete a key-value pair : del keyword is used to delete a key-
value pair from a dictionary
Syntax: del dictionaryName[“key”]
Copy a dictionary into another : is used to copy the contents of
one dictionary to another
Syntax: dictionaryTwo = dictionaryOne.copy()
Clear a dictionary: is used to clear the contents of a dictionary
and make it empty .
22. Condition statements are a block of
statements whose execution depends on a
certain condition.
Indentation play a very important role over
here.
Different type of condition statements:
1. If statement
2. If-else statement
3. If-elif-else statement
4. Nested if
Control
Statement
(Condition)
25. Loop statements : Looping is used to repeatedly
perform a block of statements over and over again.
Different type of loop statements:
1. For loop
2. While loop
Control
Statement
(Loop)
26. 1. For loop
statement
• The number of iterations to
be performed depends upon
the length of the list
• Syntax:
for count in list:
statement 1
statement 2…
statement n
• Here count is a iterative
variable who’s value start
from first value of the list .
• And, list is the array in
python.
• end = ‘ ’ is used to end the
print statement with a
white space instead of a
new line.
27. 2.While loop
statement
• It repeatedly execute a
block of statements as long
as the condition mentioned
holds true.
Syntax:
while condition:
statement 1
statement 2…
statement n
• Here condition is used to
control the statement.
• while True: statement used
for infinite no of iteration.
28. Additional
Statement
Break: A break
statement is used to
stop a loop from
further execution.
Example:
>>>len=1
>>>while len>0:
if len == 3:
break
print(len)
len=len+1
Else:The block of
statements in the else
block gets executed if
the break statement
in the looping
condition was
executed.
Example:
>>> len=1
>>>while len<=3:
if len ==5:
break
print(len)
len=len+1
else:
print(“Break
statement was
executed”)
Continue: Continue
statement is used to
skip a particular
iteration of the loop.
Example:
>>> len = 1
>>>while len<=4:
if len ==2:
len=len+1
continue
print(len)
len=len+1
30. Real world
Application of
Python
BitTorrent is made up in Python
Web and Internet Development
Scientific and Numeric: SciPy, Pandas, Ipython
Business Applications : Odoo, Tryton
Source: topdevelopers.co%2Fblog%2F10-reasons-to-choose-python-web-development-project%2F&psig=AOvVaw
2drpI11_4MB70 UCf_c7W0S&ust=1589011542035214