SlideShare a Scribd company logo
1 of 28
Download to read offline
Python for everyone
Ashwani Jha
SDE-1, Amazon
@codingpros.in
Ashutosh Tiwari
SDE-1, Oracle
@codingpros.in
+91-6204143576
What is Python?
Python is an interpreted, object-oriented,
high-level programming language with
dynamic semantics.
Python/Inventor
Guido van Rossum
It was created by Guido van Rossum, and
first released on February 20, 1991.
Interpreted
Object Oriented
High-level
Dynamic semantics.
More info: https://www.python.org/doc/essays/blurb/
Why Python?
Python’s popularity
Python is used in Data Science
Python’s scripting & automation
Python is used with Big Data
Python supports Testing
Computer Graphics in Python
Python used in Artificial Intelligence
Python in Web Development
Python is portable & extensible
Python is simple & easy to learn
Large Community support
Getting started
https://repl.it/languages/python3
Online Python interpreter:
Video Placeholder
Python Data types
Operators and Expressions
1. Arithmetic Operators
2. Relational/Comparison Operators
3. Logical Operators (and, or, not)
4. Bitwise Operators (&, |, ~, ^, >>, <<)
5. Assignment operators ( = )
6. Identity operators (is, is not)
7. Membership operators(in, not in)
Video Placeholder
Input and Output
# Taking input from the user
name = input("Enter your name: ")
# Output
print("Hello, " + name)
Lists
a = ['foo', 'bar', 'baz', 'qux', 'quux', 'corge']
Tuple
t = ('foo', 'bar', 'baz', 'qux', 'quux', 'corge')
Isn’t it the same?
Lists vs Tuples
https://stackoverflow.com/questions/2174124/why-do-we-ne
ed-tuples-in-python-or-any-immutable-data-type
So, why the ……. do we need
Tuples?
1. immutable objects can allow substantial optimization; this is
presumably why strings are also immutable in Java, developed
quite separately but about the same time as Python, and just about
everything is immutable in truly-functional languages.
2. in Python in particular, only immutables can be hashable (and,
therefore, members of sets, or keys in dictionaries). Again, this
afford optimization, but far more than just "substantial" (designing
decent hash tables storing completely mutable objects is a
nightmare -- either you take copies of everything as soon as you
hash it, or the nightmare of checking whether the object's hash has
changed since you last took a reference to it rears its ugly head).
Sets and Dictionaries
A Set is an unordered collection data type that is iterable, mutable and
has no duplicate elements. Python’s set class represents the
mathematical notion of a set. The major advantage of using a set, as
opposed to a list, is that it has a highly optimized method for checking
whether a specific element is contained in the set.
Dictionary in Python is an unordered collection of data values, used to store
data values like a map, which unlike other Data Types that hold only single
value as an element, Dictionary holds key:value pair. Key value is provided in
the dictionary to make it more optimized.
Using Sets
Set:
myset = set(["a", "b", "c"])
Also_a_set = {“a”, “b”, “c”}
# Adding element to the set
myset.add("d")
print(myset)
print(Also_a_set)
#Output:
{“d”, “c”, “a”, “b”}
{“a”, “b”, c”}
Using Dictionaries
Dictionary:
# Creating a Dictionary
# with Integer Keys
Dict = {1: 'Geeks', 2: 'For', 3: 'Geeks'}
print("nDictionary with the use of Integer Keys: ")
print(Dict)
# Creating a Dictionary
# with Mixed keys
Dict = {'Name': 'Geeks', 1: [1, 2, 3, 4]}
print("Dictionary with the use of Mixed Keys: ")
print(Dict)
How Do Dictionaries and Sets Work?
Dictionaries and sets use hash tables in order to achieve their O(1)
lookups and insertions. This efficiency is the result of a very clever
usage of a hash function to turn an arbitrary key (i.e., a string or
object) into an index for a list. The hash function and list can later
be used to determine where any particular piece of data is right
away, without a search. By turning the data’s key into something
that can be used like a list index, we can get the same
performance as with a list. In addition, instead of having to refer to
data by a numerical index, which itself implies some ordering to the
data, we can refer to it by this arbitrary key.
How Do Dictionaries and Sets Work?
hashcode = hash(key)
Index = hashcode%x
Index = hashcode&(n-1)
Index = func(hashcode)
Lookup time: O(1)
https://www.codingpros.in/
You can use a List to store the steps necessary to cook a chicken, because Lists
support sequential access and you can access the steps in order.
You can use a Tuple to store the latitude and longitude of your home, because a
tuple always has a predefined number of elements (in this specific example, two).
The same Tuple type can be used to store the coordinates of other locations.
You can use a Set to store passport numbers, because a Set enforces uniqueness
among its elements. Passport numbers are always unique and two people can't have
the same one.
You can use a dictionary to store roll numbers and name of students in a class.
(https://en.wikipedia.org/wiki/Map_(higher-order_function) )
Ok… but…. Where do we use all of it?
Decision Making in
Python
num = 3
if num >= 5:
print("Greater than 5")
elif (num<5 and num>0):
print(“+ve and Less than 5”)
else:
print("Negative number")
Loops (On and on we go)
count = 0
while (count < 3):
count = count + 1
print("Hello Geek")
n = 4
for i in range(0, n):
print(i)
Functions
def function_name(parameters):
"""docstring"""
statement(s)
def evenOdd(x):
if (x % 2 == 0):
print "even"
else:
print "odd"
def myFun(x, y=50):
print("x: ", x)
print("y: ", y
Let’s use what we have just learnt to
build a calculator:
https://repl.it/languages/python3
How to get into product based
companies like Amazon?
Practice
Practice more
Get a mentor
Don’t be in doubts. Get it cleared!
Have past work that shows impact.
Let codingpros.in help you!
Thank you!
Q and A
WWW.CODINGPROS.IN
@codingpros.in
+91-6204143576
contact@codingpros.in

More Related Content

Similar to Python for Everybody - Solution Challenge 2021

python full notes data types string and tuple
python full notes data types string and tuplepython full notes data types string and tuple
python full notes data types string and tuple
SukhpreetSingh519414
 

Similar to Python for Everybody - Solution Challenge 2021 (20)

Phython presentation
Phython presentationPhython presentation
Phython presentation
 
python full notes data types string and tuple
python full notes data types string and tuplepython full notes data types string and tuple
python full notes data types string and tuple
 
Shivam PPT.pptx
Shivam PPT.pptxShivam PPT.pptx
Shivam PPT.pptx
 
Government Polytechnic Arvi-1.pptx
Government Polytechnic Arvi-1.pptxGovernment Polytechnic Arvi-1.pptx
Government Polytechnic Arvi-1.pptx
 
Data structures in c#
Data structures in c#Data structures in c#
Data structures in c#
 
set.pptx
set.pptxset.pptx
set.pptx
 
Data Science Using Python.pptx
Data Science Using Python.pptxData Science Using Python.pptx
Data Science Using Python.pptx
 
Introduction To Python
Introduction To PythonIntroduction To Python
Introduction To Python
 
PYTHON 101.pptx
PYTHON 101.pptxPYTHON 101.pptx
PYTHON 101.pptx
 
Introduction to Python Objects and Strings
Introduction to Python Objects and StringsIntroduction to Python Objects and Strings
Introduction to Python Objects and Strings
 
Python 3.x quick syntax guide
Python 3.x quick syntax guidePython 3.x quick syntax guide
Python 3.x quick syntax guide
 
Data Structures.pdf
Data Structures.pdfData Structures.pdf
Data Structures.pdf
 
Week 10.pptx
Week 10.pptxWeek 10.pptx
Week 10.pptx
 
Souvenir's Booth - Algorithm Design and Analysis Project Project Report
Souvenir's Booth - Algorithm Design and Analysis Project Project ReportSouvenir's Booth - Algorithm Design and Analysis Project Project Report
Souvenir's Booth - Algorithm Design and Analysis Project Project Report
 
Python interview questions and answers
Python interview questions and answersPython interview questions and answers
Python interview questions and answers
 
Python interview questions and answers
Python interview questions and answersPython interview questions and answers
Python interview questions and answers
 
Zero to Hero - Introduction to Python3
Zero to Hero - Introduction to Python3Zero to Hero - Introduction to Python3
Zero to Hero - Introduction to Python3
 
Mapping Data Types In Python.pptx
Mapping Data Types In Python.pptxMapping Data Types In Python.pptx
Mapping Data Types In Python.pptx
 
bhaskars.pptx
bhaskars.pptxbhaskars.pptx
bhaskars.pptx
 
Toolboxes for data scientists
Toolboxes for data scientistsToolboxes for data scientists
Toolboxes for data scientists
 

More from AshwinRaj57

More from AshwinRaj57 (6)

Foundation of UI/UX
Foundation of UI/UXFoundation of UI/UX
Foundation of UI/UX
 
Revamp Your CV
Revamp Your CVRevamp Your CV
Revamp Your CV
 
Git and GitHub
Git and GitHubGit and GitHub
Git and GitHub
 
Information session - UCEK DSC
Information session - UCEK DSCInformation session - UCEK DSC
Information session - UCEK DSC
 
Prior programming experience track
Prior programming experience trackPrior programming experience track
Prior programming experience track
 
30 Days of Google Cloud
30 Days of Google Cloud30 Days of Google Cloud
30 Days of Google Cloud
 

Recently uploaded

Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
Epec Engineered Technologies
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Kandungan 087776558899
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
dollysharma2066
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ssuser89054b
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
amitlee9823
 

Recently uploaded (20)

Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 

Python for Everybody - Solution Challenge 2021

  • 1.
  • 2. Python for everyone Ashwani Jha SDE-1, Amazon @codingpros.in Ashutosh Tiwari SDE-1, Oracle @codingpros.in +91-6204143576
  • 3. What is Python? Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. Python/Inventor Guido van Rossum It was created by Guido van Rossum, and first released on February 20, 1991. Interpreted Object Oriented High-level Dynamic semantics. More info: https://www.python.org/doc/essays/blurb/
  • 4. Why Python? Python’s popularity Python is used in Data Science Python’s scripting & automation Python is used with Big Data Python supports Testing Computer Graphics in Python Python used in Artificial Intelligence Python in Web Development Python is portable & extensible Python is simple & easy to learn Large Community support
  • 7. Operators and Expressions 1. Arithmetic Operators 2. Relational/Comparison Operators 3. Logical Operators (and, or, not) 4. Bitwise Operators (&, |, ~, ^, >>, <<) 5. Assignment operators ( = ) 6. Identity operators (is, is not) 7. Membership operators(in, not in)
  • 8. Video Placeholder Input and Output # Taking input from the user name = input("Enter your name: ") # Output print("Hello, " + name)
  • 9. Lists a = ['foo', 'bar', 'baz', 'qux', 'quux', 'corge']
  • 10. Tuple t = ('foo', 'bar', 'baz', 'qux', 'quux', 'corge')
  • 11. Isn’t it the same?
  • 13. https://stackoverflow.com/questions/2174124/why-do-we-ne ed-tuples-in-python-or-any-immutable-data-type So, why the ……. do we need Tuples? 1. immutable objects can allow substantial optimization; this is presumably why strings are also immutable in Java, developed quite separately but about the same time as Python, and just about everything is immutable in truly-functional languages. 2. in Python in particular, only immutables can be hashable (and, therefore, members of sets, or keys in dictionaries). Again, this afford optimization, but far more than just "substantial" (designing decent hash tables storing completely mutable objects is a nightmare -- either you take copies of everything as soon as you hash it, or the nightmare of checking whether the object's hash has changed since you last took a reference to it rears its ugly head).
  • 14. Sets and Dictionaries A Set is an unordered collection data type that is iterable, mutable and has no duplicate elements. Python’s set class represents the mathematical notion of a set. The major advantage of using a set, as opposed to a list, is that it has a highly optimized method for checking whether a specific element is contained in the set. Dictionary in Python is an unordered collection of data values, used to store data values like a map, which unlike other Data Types that hold only single value as an element, Dictionary holds key:value pair. Key value is provided in the dictionary to make it more optimized.
  • 15. Using Sets Set: myset = set(["a", "b", "c"]) Also_a_set = {“a”, “b”, “c”} # Adding element to the set myset.add("d") print(myset) print(Also_a_set) #Output: {“d”, “c”, “a”, “b”} {“a”, “b”, c”}
  • 16. Using Dictionaries Dictionary: # Creating a Dictionary # with Integer Keys Dict = {1: 'Geeks', 2: 'For', 3: 'Geeks'} print("nDictionary with the use of Integer Keys: ") print(Dict) # Creating a Dictionary # with Mixed keys Dict = {'Name': 'Geeks', 1: [1, 2, 3, 4]} print("Dictionary with the use of Mixed Keys: ") print(Dict)
  • 17. How Do Dictionaries and Sets Work? Dictionaries and sets use hash tables in order to achieve their O(1) lookups and insertions. This efficiency is the result of a very clever usage of a hash function to turn an arbitrary key (i.e., a string or object) into an index for a list. The hash function and list can later be used to determine where any particular piece of data is right away, without a search. By turning the data’s key into something that can be used like a list index, we can get the same performance as with a list. In addition, instead of having to refer to data by a numerical index, which itself implies some ordering to the data, we can refer to it by this arbitrary key.
  • 18. How Do Dictionaries and Sets Work? hashcode = hash(key) Index = hashcode%x Index = hashcode&(n-1) Index = func(hashcode) Lookup time: O(1)
  • 20. You can use a List to store the steps necessary to cook a chicken, because Lists support sequential access and you can access the steps in order. You can use a Tuple to store the latitude and longitude of your home, because a tuple always has a predefined number of elements (in this specific example, two). The same Tuple type can be used to store the coordinates of other locations. You can use a Set to store passport numbers, because a Set enforces uniqueness among its elements. Passport numbers are always unique and two people can't have the same one. You can use a dictionary to store roll numbers and name of students in a class. (https://en.wikipedia.org/wiki/Map_(higher-order_function) ) Ok… but…. Where do we use all of it?
  • 21. Decision Making in Python num = 3 if num >= 5: print("Greater than 5") elif (num<5 and num>0): print(“+ve and Less than 5”) else: print("Negative number")
  • 22. Loops (On and on we go) count = 0 while (count < 3): count = count + 1 print("Hello Geek") n = 4 for i in range(0, n): print(i)
  • 24. def function_name(parameters): """docstring""" statement(s) def evenOdd(x): if (x % 2 == 0): print "even" else: print "odd" def myFun(x, y=50): print("x: ", x) print("y: ", y
  • 25. Let’s use what we have just learnt to build a calculator: https://repl.it/languages/python3
  • 26. How to get into product based companies like Amazon? Practice Practice more Get a mentor Don’t be in doubts. Get it cleared! Have past work that shows impact. Let codingpros.in help you!