SlideShare a Scribd company logo
1 of 32
Introduction to the basic of
Python programming
BY TIB Academy(Tibacademy@gmail.compython.com)
A little about me
{
“Name”: “TIB Academy”,
“Origin”: {“India”: “Bangalore”, “City”:
“Lives”: [“Bangalore”, 2016],
“Marathalli”},
“Other”: [:“Trainer”, “Start a Career with Python”]
}
Why this Meetup Group?
 Promote the usage of Python
Gather people from different industries and backgrounds
Teach and Learn


What will be covered
 Recap of Parts 1 and 2
import, Modules and Packages
Python in action
Note: Links
www.tibacademy.in
www.traininginbangalore.com


A little recap
 Python is an interpreted language (CPython is the reference interpreter)
Variables are names bound to objects stored in memory
Data Types: immutable or mutable
Data Types: Numbers (int, float, bool), Sequences (str, tuple, list, bytes,
bytearray), set, dict
Control Flow: if statement, for loop, while loop
Iterables are container objects capable of returning their elements one at a time
Iterators implement the methods iter and next






A little recap
 Python is an interpreted language (CPython is the reference interpreter)
Variables are names bound to objects stored in memory
Data Types: immutable or mutable
Data Types: Numbers (int, float, bool), Sequences (str, tuple, list, bytes,
bytearray), set, dict
Control Flow: if statement, for loop, while loop
Iterables are container objects capable of returning their elements one at a time
Iterators implement the methods iter and next






A little recap
 Python is an interpreted language (CPython is the reference interpreter)
Variables are names bound to objects stored in memory
Data Types: immutable or mutable
Data Types: Numbers (int, float, bool), Sequences (str, tuple, list, bytes,
bytearray), set, dict
Control Flow: if statement, for loop, while loop
Iterables are container objects capable of returning their elements one at a time
Iterators implement the methods iter and next






A little recap
>>>
4
>>>
2.0
>>>
True
>>>
>>>
(1,
2 + 2
4 / 2
4 > 2
x
x
= 1, 2
2)
A little recap
>>>
>>>
[1,
>>>
>>>
{1,
>>>
>>>
x =
x
2]
x =
x
2}
x =
x
[1, 2]
{1, 2}
{"one": 1, "two": 2}
{'two': 2, 'one': 1}
A little recap
 Python is an interpreted language (CPython is the reference interpreter)
Variables are names bound to objects stored in memory
Data Types: immutable or mutable
Data Types: Numbers (int, float, bool), Sequences (str, tuple, list, bytes,
bytearray), set, dict
Control Flow: if statement, for loop, while loop
Iterables are container objects capable of returning their elements one at a time
Iterators implement the methods iter and next






A little recap
if x % 3 == 0 and x % 5 == 0:
return
elif x % 3
return
elif x % 5
return
else:
return
"FizzBuzz"
== 0:
"Fizz"
== 0:
"Buzz"
x
A little recap
colors = ["red", "green",
for color in colors:
if len(color) > 4:
print(color)
"blue", "yellow", "purple"]
stack = [1, 2, 3]
while len(stack) > 0:
print(stack.pop())
A little recap
 Python is an interpreted language (CPython is the reference interpreter)
Variables are names bound to objects stored in memory
Data Types: immutable or mutable
Data Types: Numbers (int, float, bool), Sequences (str, tuple, list, bytes,
bytearray), set, dict
Control Flow: if statement, for loop, while loop
Iterables are container objects capable of returning their elements one at a time
Iterators implement the methods iter and next






A little recap
>>>
>>>
>>>
colors = ["red", "green", "blue",
colors_iter = colors. iter ()
"yellow", "purple"]
colors_iter
<list_iterator object at 0x100c7a160>
>>> colors_iter. next__()
'red'
…
>>> colors_iter. next__()
'purple'
>>> colors_iter. next__()
Traceback (most recent call last): File
<module>
StopIteration
"<stdin>", line 1, in
A little recap
colors = [(0, "red"), (1, "blue"), (2, "green"), (3, "yellow")]
for index, color
print(index,
in colors:
" --> ", color)
colors = ["red",
for index, color
print(index,
"blue", "green", "yellow", "purple"]
in enumerate(colors):
" --> ", color)
A little recap
 List comprehensions
Dictionary comprehensions
Functions


 Positional Arguments
Keyword Arguments
Default parameters
Variable number of arguments



A little recap
colors = ["red", "green", "blue", "yellow", "purple"]
new_colors = []
for color in colors:
if len(color) > 4:
new_colors.append(color)
new_colors = [color for color in colors if len(color) > 4]
Challenge
 Given a list of colors, create a new list with all the colors in uppercase. Use list
comprehensions.
colors = ["red", "green", "blue", "yellow", "purple"]
upper_colors = []
for color in colors:
upper_colors.append(color.upper())
A little recap
 List comprehensions
Dictionary comprehensions
Functions


 Positional Arguments
Keyword Arguments
Default parameters
Variable number of arguments



A little recap
squares = {}
for i in range(10):
squares[i] = i**2
squares = {i:i**2 for i in range(10)}
{0: 0, 1: 1, 2: 4, 3:
81}
9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64, 9:
Challenge
 Given a list of colors, create a dictionary where each key is a color and the value is
the color written backwards. Use dict comprehensions.
colors = ["red", "green", "blue", "yellow", "purple"]
backwards_colors = {}
for color in colors:
backwards_colors[color] = color[::-1]
A little recap
 List comprehensions
Dictionary comprehensions
Functions


 Positional Arguments
Keyword Arguments
Default parameters
Variable number of arguments



A little recap
def say_hello():
print("Hello")
def add_squares(a, b):
return a**2 + b**2
>>>
13
add_squares(2, 3)
def add_squares(a, b=3):
return a**2 + b**2
>>>
13
add_squares(2)
A little recap
def add_squares(a, b):
return a**2 + b**2
>>> add_squares(b=3, a=2)
13
A little recap
def add_aquares(*args):
if len(args) == 2:
return args[0]**2 + args[1]**2
>>> add_squares(2, 3)
13
A little recap
def add_squares(**kwargs):
if len(kwargs) == 2:
return kwargs["a"]**2 + kwargs["b"]**2
>>> add_squares(a=2, b=3)
13
Challenge
 Define a function that turns a string into a list of int (operands) and strings (operators) and returns
the list.
>>>
[4,
>>>
[4,
_convert_expression("4
3, "+"]
_convert_expression("4
3, "+", 2, "*"]
3 +")
3 + 2 *")
 Hints:
 “a b”.split(“ “) = [“a”, “b”]
“a”.isnumeric() = False
int(“2”) = 2


 Kudos for who solves in one line using lambdas and list comprehensions.
Challenge
 RPN = Reverse Polish Notation
4 3 + (7)
4 3 + 2 * (14)
Extend RPN calculator to support the operators *, / and sqrt (from math module).



import math
print(math.sqrt(4))
Modules and Packages
 A module is a file with definitions and statements
It’s named after the file.
Modules are imported with import statement
 import <module>
 from <module> import <name1>
 from <module> import <name1>, <name2>
 import <module> as <new_module_name>
 from <module> import <name1> as <new_name1>
 from <module> import *


Modules and Packages
 A package is a directory with a special file init .py (the file can be empty, and
it’s also not mandatory to exist)
The file init .py is executed when importing a package.
 Packages can contain other packages.
Modules and Packags
api/
init .py
rest.py
server.py
services/
init .py
rpn.py
hello.py
$ python -m api.server
Modules and Packages
 import api
 from api import rest
 import api.services.rpn
 from api.services.hello import say_hello
Thank you

More Related Content

What's hot

13. Java text processing
13.  Java text processing13.  Java text processing
13. Java text processingIntro C# Book
 
Python Datatypes by SujithKumar
Python Datatypes by SujithKumarPython Datatypes by SujithKumar
Python Datatypes by SujithKumarSujith Kumar
 
18. Dictionaries, Hash-Tables and Set
18. Dictionaries, Hash-Tables and Set18. Dictionaries, Hash-Tables and Set
18. Dictionaries, Hash-Tables and SetIntro C# Book
 
16. Arrays Lists Stacks Queues
16. Arrays Lists Stacks Queues16. Arrays Lists Stacks Queues
16. Arrays Lists Stacks QueuesIntro C# Book
 
19. Java data structures algorithms and complexity
19. Java data structures algorithms and complexity19. Java data structures algorithms and complexity
19. Java data structures algorithms and complexityIntro C# Book
 
Learn python - for beginners - part-2
Learn python - for beginners - part-2Learn python - for beginners - part-2
Learn python - for beginners - part-2RajKumar Rampelli
 
7 Habits For a More Functional Swift
7 Habits For a More Functional Swift7 Habits For a More Functional Swift
7 Habits For a More Functional SwiftJason Larsen
 
G3 Summit 2016 - Taking Advantage of Groovy Annotations
G3 Summit 2016 - Taking Advantage of Groovy AnnotationsG3 Summit 2016 - Taking Advantage of Groovy Annotations
G3 Summit 2016 - Taking Advantage of Groovy AnnotationsIván López Martín
 
Python3 cheatsheet
Python3 cheatsheetPython3 cheatsheet
Python3 cheatsheetGil Cohen
 
Datatypes in python
Datatypes in pythonDatatypes in python
Datatypes in pythoneShikshak
 
Python tutorialfeb152012
Python tutorialfeb152012Python tutorialfeb152012
Python tutorialfeb152012Shani729
 
Python programming Part -6
Python programming Part -6Python programming Part -6
Python programming Part -6Megha V
 
Python tutorial
Python tutorialPython tutorial
Python tutorialRajiv Risi
 
Collections Framework
Collections FrameworkCollections Framework
Collections FrameworkSunil OS
 

What's hot (20)

13. Java text processing
13.  Java text processing13.  Java text processing
13. Java text processing
 
Python Datatypes by SujithKumar
Python Datatypes by SujithKumarPython Datatypes by SujithKumar
Python Datatypes by SujithKumar
 
Python Cheat Sheet
Python Cheat SheetPython Cheat Sheet
Python Cheat Sheet
 
18. Dictionaries, Hash-Tables and Set
18. Dictionaries, Hash-Tables and Set18. Dictionaries, Hash-Tables and Set
18. Dictionaries, Hash-Tables and Set
 
Python course Day 1
Python course Day 1Python course Day 1
Python course Day 1
 
16. Arrays Lists Stacks Queues
16. Arrays Lists Stacks Queues16. Arrays Lists Stacks Queues
16. Arrays Lists Stacks Queues
 
19. Java data structures algorithms and complexity
19. Java data structures algorithms and complexity19. Java data structures algorithms and complexity
19. Java data structures algorithms and complexity
 
Python_ 3 CheatSheet
Python_ 3 CheatSheetPython_ 3 CheatSheet
Python_ 3 CheatSheet
 
Learn python - for beginners - part-2
Learn python - for beginners - part-2Learn python - for beginners - part-2
Learn python - for beginners - part-2
 
Pune Clojure Course Outline
Pune Clojure Course OutlinePune Clojure Course Outline
Pune Clojure Course Outline
 
7 Habits For a More Functional Swift
7 Habits For a More Functional Swift7 Habits For a More Functional Swift
7 Habits For a More Functional Swift
 
G3 Summit 2016 - Taking Advantage of Groovy Annotations
G3 Summit 2016 - Taking Advantage of Groovy AnnotationsG3 Summit 2016 - Taking Advantage of Groovy Annotations
G3 Summit 2016 - Taking Advantage of Groovy Annotations
 
Python3 cheatsheet
Python3 cheatsheetPython3 cheatsheet
Python3 cheatsheet
 
Datatypes in python
Datatypes in pythonDatatypes in python
Datatypes in python
 
Python tutorialfeb152012
Python tutorialfeb152012Python tutorialfeb152012
Python tutorialfeb152012
 
Python programming Part -6
Python programming Part -6Python programming Part -6
Python programming Part -6
 
Python tutorial
Python tutorialPython tutorial
Python tutorial
 
Comparing JVM languages
Comparing JVM languagesComparing JVM languages
Comparing JVM languages
 
Collections Framework
Collections FrameworkCollections Framework
Collections Framework
 
01. haskell introduction
01. haskell introduction01. haskell introduction
01. haskell introduction
 

Similar to Python Training

Introduction to the basics of Python programming (part 3)
Introduction to the basics of Python programming (part 3)Introduction to the basics of Python programming (part 3)
Introduction to the basics of Python programming (part 3)Pedro Rodrigues
 
Python Interview Questions | Python Interview Questions And Answers | Python ...
Python Interview Questions | Python Interview Questions And Answers | Python ...Python Interview Questions | Python Interview Questions And Answers | Python ...
Python Interview Questions | Python Interview Questions And Answers | Python ...Simplilearn
 
Introducción a Elixir
Introducción a ElixirIntroducción a Elixir
Introducción a ElixirSvet Ivantchev
 
Python Programming: Data Structure
Python Programming: Data StructurePython Programming: Data Structure
Python Programming: Data StructureChan Shik Lim
 
Using-Python-Libraries.9485146.powerpoint.pptx
Using-Python-Libraries.9485146.powerpoint.pptxUsing-Python-Libraries.9485146.powerpoint.pptx
Using-Python-Libraries.9485146.powerpoint.pptxUadAccount
 
Python bootcamp - C4Dlab, University of Nairobi
Python bootcamp - C4Dlab, University of NairobiPython bootcamp - C4Dlab, University of Nairobi
Python bootcamp - C4Dlab, University of Nairobikrmboya
 
Python 101++: Let's Get Down to Business!
Python 101++: Let's Get Down to Business!Python 101++: Let's Get Down to Business!
Python 101++: Let's Get Down to Business!Paige Bailey
 
python-cheatsheets.pdf
python-cheatsheets.pdfpython-cheatsheets.pdf
python-cheatsheets.pdfKalyan969491
 
python-cheatsheets that will be for coders
python-cheatsheets that will be for coderspython-cheatsheets that will be for coders
python-cheatsheets that will be for coderssarafbisesh
 
UNIT III_Python Programming_aditya COllege
UNIT III_Python Programming_aditya COllegeUNIT III_Python Programming_aditya COllege
UNIT III_Python Programming_aditya COllegeRamanamurthy Banda
 
UNIT III_Python Programming_aditya COllege
UNIT III_Python Programming_aditya COllegeUNIT III_Python Programming_aditya COllege
UNIT III_Python Programming_aditya COllegeRamanamurthy Banda
 
01-Python-Basics.ppt
01-Python-Basics.ppt01-Python-Basics.ppt
01-Python-Basics.pptVicVic56
 
An overview of Python 2.7
An overview of Python 2.7An overview of Python 2.7
An overview of Python 2.7decoupled
 
Introduction to python programming 1
Introduction to python programming   1Introduction to python programming   1
Introduction to python programming 1Giovanni Della Lunga
 
Python programming workshop session 3
Python programming workshop session 3Python programming workshop session 3
Python programming workshop session 3Abdul Haseeb
 

Similar to Python Training (20)

Introduction to the basics of Python programming (part 3)
Introduction to the basics of Python programming (part 3)Introduction to the basics of Python programming (part 3)
Introduction to the basics of Python programming (part 3)
 
Python Interview Questions | Python Interview Questions And Answers | Python ...
Python Interview Questions | Python Interview Questions And Answers | Python ...Python Interview Questions | Python Interview Questions And Answers | Python ...
Python Interview Questions | Python Interview Questions And Answers | Python ...
 
Intro
IntroIntro
Intro
 
Introducción a Elixir
Introducción a ElixirIntroducción a Elixir
Introducción a Elixir
 
Python Programming: Data Structure
Python Programming: Data StructurePython Programming: Data Structure
Python Programming: Data Structure
 
Using-Python-Libraries.9485146.powerpoint.pptx
Using-Python-Libraries.9485146.powerpoint.pptxUsing-Python-Libraries.9485146.powerpoint.pptx
Using-Python-Libraries.9485146.powerpoint.pptx
 
Biopython: Overview, State of the Art and Outlook
Biopython: Overview, State of the Art and OutlookBiopython: Overview, State of the Art and Outlook
Biopython: Overview, State of the Art and Outlook
 
Python bootcamp - C4Dlab, University of Nairobi
Python bootcamp - C4Dlab, University of NairobiPython bootcamp - C4Dlab, University of Nairobi
Python bootcamp - C4Dlab, University of Nairobi
 
Python 101++: Let's Get Down to Business!
Python 101++: Let's Get Down to Business!Python 101++: Let's Get Down to Business!
Python 101++: Let's Get Down to Business!
 
python-cheatsheets.pdf
python-cheatsheets.pdfpython-cheatsheets.pdf
python-cheatsheets.pdf
 
python-cheatsheets that will be for coders
python-cheatsheets that will be for coderspython-cheatsheets that will be for coders
python-cheatsheets that will be for coders
 
UNIT III_Python Programming_aditya COllege
UNIT III_Python Programming_aditya COllegeUNIT III_Python Programming_aditya COllege
UNIT III_Python Programming_aditya COllege
 
UNIT III_Python Programming_aditya COllege
UNIT III_Python Programming_aditya COllegeUNIT III_Python Programming_aditya COllege
UNIT III_Python Programming_aditya COllege
 
Python for Dummies
Python for DummiesPython for Dummies
Python for Dummies
 
01-Python-Basics.ppt
01-Python-Basics.ppt01-Python-Basics.ppt
01-Python-Basics.ppt
 
An overview of Python 2.7
An overview of Python 2.7An overview of Python 2.7
An overview of Python 2.7
 
A tour of Python
A tour of PythonA tour of Python
A tour of Python
 
Faster Python, FOSDEM
Faster Python, FOSDEMFaster Python, FOSDEM
Faster Python, FOSDEM
 
Introduction to python programming 1
Introduction to python programming   1Introduction to python programming   1
Introduction to python programming 1
 
Python programming workshop session 3
Python programming workshop session 3Python programming workshop session 3
Python programming workshop session 3
 

More from TIB Academy

AWS Training Institute in Bangalore | Best AWS Course In Bangalore
AWS Training Institute in Bangalore | Best AWS Course In BangaloreAWS Training Institute in Bangalore | Best AWS Course In Bangalore
AWS Training Institute in Bangalore | Best AWS Course In BangaloreTIB Academy
 
MySQL training in Bangalore | Best MySQL Course in Bangalore
MySQL training in Bangalore | Best MySQL Course in BangaloreMySQL training in Bangalore | Best MySQL Course in Bangalore
MySQL training in Bangalore | Best MySQL Course in BangaloreTIB Academy
 
CCNA Training in Bangalore | Best Networking course in Bangalore
CCNA Training in Bangalore | Best Networking course in BangaloreCCNA Training in Bangalore | Best Networking course in Bangalore
CCNA Training in Bangalore | Best Networking course in BangaloreTIB Academy
 
Core Java Training in Bangalore | Best Core Java Class in Bangalore
Core Java Training in Bangalore | Best Core Java Class in BangaloreCore Java Training in Bangalore | Best Core Java Class in Bangalore
Core Java Training in Bangalore | Best Core Java Class in BangaloreTIB Academy
 
Advance Java Training in Bangalore | Best Java Training Institute
Advance Java Training in Bangalore | Best Java Training Institute Advance Java Training in Bangalore | Best Java Training Institute
Advance Java Training in Bangalore | Best Java Training Institute TIB Academy
 
Best Hadoop Training in Bangalore - TIB Academy
Best Hadoop Training in Bangalore - TIB AcademyBest Hadoop Training in Bangalore - TIB Academy
Best Hadoop Training in Bangalore - TIB AcademyTIB Academy
 
Selenium training for beginners
Selenium training for beginnersSelenium training for beginners
Selenium training for beginnersTIB Academy
 
TIB Academy provides best Oracal DBA classes in Bangalore
TIB Academy provides best Oracal DBA classes in BangaloreTIB Academy provides best Oracal DBA classes in Bangalore
TIB Academy provides best Oracal DBA classes in BangaloreTIB Academy
 
java tutorial for beginner - Free Download
java tutorial for beginner - Free Downloadjava tutorial for beginner - Free Download
java tutorial for beginner - Free DownloadTIB Academy
 
Aws tutorial for beginners- tibacademy.in
Aws tutorial for beginners- tibacademy.inAws tutorial for beginners- tibacademy.in
Aws tutorial for beginners- tibacademy.inTIB Academy
 
C C++ tutorial for beginners- tibacademy.in
C C++ tutorial for beginners- tibacademy.inC C++ tutorial for beginners- tibacademy.in
C C++ tutorial for beginners- tibacademy.inTIB Academy
 
Java tutorial for beginners-tibacademy.in
Java tutorial for beginners-tibacademy.inJava tutorial for beginners-tibacademy.in
Java tutorial for beginners-tibacademy.inTIB Academy
 
Android tutorial for beginners-traininginbangalore.com
Android tutorial for beginners-traininginbangalore.comAndroid tutorial for beginners-traininginbangalore.com
Android tutorial for beginners-traininginbangalore.comTIB Academy
 
Hadoop tutorial for beginners-tibacademy.in
Hadoop tutorial for beginners-tibacademy.inHadoop tutorial for beginners-tibacademy.in
Hadoop tutorial for beginners-tibacademy.inTIB Academy
 
SoapUI Training in Bangalore
SoapUI Training in BangaloreSoapUI Training in Bangalore
SoapUI Training in BangaloreTIB Academy
 
Spring-training-in-bangalore
Spring-training-in-bangaloreSpring-training-in-bangalore
Spring-training-in-bangaloreTIB Academy
 
Salesforce Certification
Salesforce CertificationSalesforce Certification
Salesforce CertificationTIB Academy
 

More from TIB Academy (18)

AWS Training Institute in Bangalore | Best AWS Course In Bangalore
AWS Training Institute in Bangalore | Best AWS Course In BangaloreAWS Training Institute in Bangalore | Best AWS Course In Bangalore
AWS Training Institute in Bangalore | Best AWS Course In Bangalore
 
MySQL training in Bangalore | Best MySQL Course in Bangalore
MySQL training in Bangalore | Best MySQL Course in BangaloreMySQL training in Bangalore | Best MySQL Course in Bangalore
MySQL training in Bangalore | Best MySQL Course in Bangalore
 
CCNA Training in Bangalore | Best Networking course in Bangalore
CCNA Training in Bangalore | Best Networking course in BangaloreCCNA Training in Bangalore | Best Networking course in Bangalore
CCNA Training in Bangalore | Best Networking course in Bangalore
 
Core Java Training in Bangalore | Best Core Java Class in Bangalore
Core Java Training in Bangalore | Best Core Java Class in BangaloreCore Java Training in Bangalore | Best Core Java Class in Bangalore
Core Java Training in Bangalore | Best Core Java Class in Bangalore
 
Advance Java Training in Bangalore | Best Java Training Institute
Advance Java Training in Bangalore | Best Java Training Institute Advance Java Training in Bangalore | Best Java Training Institute
Advance Java Training in Bangalore | Best Java Training Institute
 
Best Hadoop Training in Bangalore - TIB Academy
Best Hadoop Training in Bangalore - TIB AcademyBest Hadoop Training in Bangalore - TIB Academy
Best Hadoop Training in Bangalore - TIB Academy
 
Selenium training for beginners
Selenium training for beginnersSelenium training for beginners
Selenium training for beginners
 
TIB Academy provides best Oracal DBA classes in Bangalore
TIB Academy provides best Oracal DBA classes in BangaloreTIB Academy provides best Oracal DBA classes in Bangalore
TIB Academy provides best Oracal DBA classes in Bangalore
 
java tutorial for beginner - Free Download
java tutorial for beginner - Free Downloadjava tutorial for beginner - Free Download
java tutorial for beginner - Free Download
 
Aws tutorial for beginners- tibacademy.in
Aws tutorial for beginners- tibacademy.inAws tutorial for beginners- tibacademy.in
Aws tutorial for beginners- tibacademy.in
 
C C++ tutorial for beginners- tibacademy.in
C C++ tutorial for beginners- tibacademy.inC C++ tutorial for beginners- tibacademy.in
C C++ tutorial for beginners- tibacademy.in
 
Java tutorial for beginners-tibacademy.in
Java tutorial for beginners-tibacademy.inJava tutorial for beginners-tibacademy.in
Java tutorial for beginners-tibacademy.in
 
Android tutorial for beginners-traininginbangalore.com
Android tutorial for beginners-traininginbangalore.comAndroid tutorial for beginners-traininginbangalore.com
Android tutorial for beginners-traininginbangalore.com
 
Hadoop tutorial for beginners-tibacademy.in
Hadoop tutorial for beginners-tibacademy.inHadoop tutorial for beginners-tibacademy.in
Hadoop tutorial for beginners-tibacademy.in
 
SoapUI Training in Bangalore
SoapUI Training in BangaloreSoapUI Training in Bangalore
SoapUI Training in Bangalore
 
R programming
R programmingR programming
R programming
 
Spring-training-in-bangalore
Spring-training-in-bangaloreSpring-training-in-bangalore
Spring-training-in-bangalore
 
Salesforce Certification
Salesforce CertificationSalesforce Certification
Salesforce Certification
 

Recently uploaded

2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxJisc
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Pooja Bhuva
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...Nguyen Thanh Tu Collection
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxCeline George
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfDr Vijay Vishwakarma
 

Recently uploaded (20)

2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 

Python Training

  • 1. Introduction to the basic of Python programming BY TIB Academy(Tibacademy@gmail.compython.com)
  • 2. A little about me { “Name”: “TIB Academy”, “Origin”: {“India”: “Bangalore”, “City”: “Lives”: [“Bangalore”, 2016], “Marathalli”}, “Other”: [:“Trainer”, “Start a Career with Python”] }
  • 3. Why this Meetup Group?  Promote the usage of Python Gather people from different industries and backgrounds Teach and Learn  
  • 4. What will be covered  Recap of Parts 1 and 2 import, Modules and Packages Python in action Note: Links www.tibacademy.in www.traininginbangalore.com  
  • 5. A little recap  Python is an interpreted language (CPython is the reference interpreter) Variables are names bound to objects stored in memory Data Types: immutable or mutable Data Types: Numbers (int, float, bool), Sequences (str, tuple, list, bytes, bytearray), set, dict Control Flow: if statement, for loop, while loop Iterables are container objects capable of returning their elements one at a time Iterators implement the methods iter and next      
  • 6. A little recap  Python is an interpreted language (CPython is the reference interpreter) Variables are names bound to objects stored in memory Data Types: immutable or mutable Data Types: Numbers (int, float, bool), Sequences (str, tuple, list, bytes, bytearray), set, dict Control Flow: if statement, for loop, while loop Iterables are container objects capable of returning their elements one at a time Iterators implement the methods iter and next      
  • 7. A little recap  Python is an interpreted language (CPython is the reference interpreter) Variables are names bound to objects stored in memory Data Types: immutable or mutable Data Types: Numbers (int, float, bool), Sequences (str, tuple, list, bytes, bytearray), set, dict Control Flow: if statement, for loop, while loop Iterables are container objects capable of returning their elements one at a time Iterators implement the methods iter and next      
  • 9. A little recap >>> >>> [1, >>> >>> {1, >>> >>> x = x 2] x = x 2} x = x [1, 2] {1, 2} {"one": 1, "two": 2} {'two': 2, 'one': 1}
  • 10. A little recap  Python is an interpreted language (CPython is the reference interpreter) Variables are names bound to objects stored in memory Data Types: immutable or mutable Data Types: Numbers (int, float, bool), Sequences (str, tuple, list, bytes, bytearray), set, dict Control Flow: if statement, for loop, while loop Iterables are container objects capable of returning their elements one at a time Iterators implement the methods iter and next      
  • 11. A little recap if x % 3 == 0 and x % 5 == 0: return elif x % 3 return elif x % 5 return else: return "FizzBuzz" == 0: "Fizz" == 0: "Buzz" x
  • 12. A little recap colors = ["red", "green", for color in colors: if len(color) > 4: print(color) "blue", "yellow", "purple"] stack = [1, 2, 3] while len(stack) > 0: print(stack.pop())
  • 13. A little recap  Python is an interpreted language (CPython is the reference interpreter) Variables are names bound to objects stored in memory Data Types: immutable or mutable Data Types: Numbers (int, float, bool), Sequences (str, tuple, list, bytes, bytearray), set, dict Control Flow: if statement, for loop, while loop Iterables are container objects capable of returning their elements one at a time Iterators implement the methods iter and next      
  • 14. A little recap >>> >>> >>> colors = ["red", "green", "blue", colors_iter = colors. iter () "yellow", "purple"] colors_iter <list_iterator object at 0x100c7a160> >>> colors_iter. next__() 'red' … >>> colors_iter. next__() 'purple' >>> colors_iter. next__() Traceback (most recent call last): File <module> StopIteration "<stdin>", line 1, in
  • 15. A little recap colors = [(0, "red"), (1, "blue"), (2, "green"), (3, "yellow")] for index, color print(index, in colors: " --> ", color) colors = ["red", for index, color print(index, "blue", "green", "yellow", "purple"] in enumerate(colors): " --> ", color)
  • 16. A little recap  List comprehensions Dictionary comprehensions Functions    Positional Arguments Keyword Arguments Default parameters Variable number of arguments   
  • 17. A little recap colors = ["red", "green", "blue", "yellow", "purple"] new_colors = [] for color in colors: if len(color) > 4: new_colors.append(color) new_colors = [color for color in colors if len(color) > 4]
  • 18. Challenge  Given a list of colors, create a new list with all the colors in uppercase. Use list comprehensions. colors = ["red", "green", "blue", "yellow", "purple"] upper_colors = [] for color in colors: upper_colors.append(color.upper())
  • 19. A little recap  List comprehensions Dictionary comprehensions Functions    Positional Arguments Keyword Arguments Default parameters Variable number of arguments   
  • 20. A little recap squares = {} for i in range(10): squares[i] = i**2 squares = {i:i**2 for i in range(10)} {0: 0, 1: 1, 2: 4, 3: 81} 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64, 9:
  • 21. Challenge  Given a list of colors, create a dictionary where each key is a color and the value is the color written backwards. Use dict comprehensions. colors = ["red", "green", "blue", "yellow", "purple"] backwards_colors = {} for color in colors: backwards_colors[color] = color[::-1]
  • 22. A little recap  List comprehensions Dictionary comprehensions Functions    Positional Arguments Keyword Arguments Default parameters Variable number of arguments   
  • 23. A little recap def say_hello(): print("Hello") def add_squares(a, b): return a**2 + b**2 >>> 13 add_squares(2, 3) def add_squares(a, b=3): return a**2 + b**2 >>> 13 add_squares(2)
  • 24. A little recap def add_squares(a, b): return a**2 + b**2 >>> add_squares(b=3, a=2) 13
  • 25. A little recap def add_aquares(*args): if len(args) == 2: return args[0]**2 + args[1]**2 >>> add_squares(2, 3) 13
  • 26. A little recap def add_squares(**kwargs): if len(kwargs) == 2: return kwargs["a"]**2 + kwargs["b"]**2 >>> add_squares(a=2, b=3) 13
  • 27. Challenge  Define a function that turns a string into a list of int (operands) and strings (operators) and returns the list. >>> [4, >>> [4, _convert_expression("4 3, "+"] _convert_expression("4 3, "+", 2, "*"] 3 +") 3 + 2 *")  Hints:  “a b”.split(“ “) = [“a”, “b”] “a”.isnumeric() = False int(“2”) = 2    Kudos for who solves in one line using lambdas and list comprehensions.
  • 28. Challenge  RPN = Reverse Polish Notation 4 3 + (7) 4 3 + 2 * (14) Extend RPN calculator to support the operators *, / and sqrt (from math module).    import math print(math.sqrt(4))
  • 29. Modules and Packages  A module is a file with definitions and statements It’s named after the file. Modules are imported with import statement  import <module>  from <module> import <name1>  from <module> import <name1>, <name2>  import <module> as <new_module_name>  from <module> import <name1> as <new_name1>  from <module> import *  
  • 30. Modules and Packages  A package is a directory with a special file init .py (the file can be empty, and it’s also not mandatory to exist) The file init .py is executed when importing a package.  Packages can contain other packages.
  • 31. Modules and Packags api/ init .py rest.py server.py services/ init .py rpn.py hello.py $ python -m api.server
  • 32. Modules and Packages  import api  from api import rest  import api.services.rpn  from api.services.hello import say_hello Thank you