SlideShare a Scribd company logo
DEV SUMMIT 2017 EXTENDED
Introduction to Python 3
Mohamed Hegazy
R&D Engineer
.PY
DEV SUMMIT 2017 EXTENDED
What is python . WIKI
• Python is a widely used high-level programming language used for general-
purpose programming. An interpreted language, Python has a design philosophy
which emphasizes code readability (notably using whitespace indentation to
delimit code blocks rather than curly braces or keywords), and a syntax which
allows programmers to express concepts in fewer lines of code than possible in
languages such as C++ or Java.The language provides constructs intended to
enable writing clear programs on both a small and large scale.
• A scripting language is a subset of programming language that is used to produce
scripts, which are sets of instructions that automate tasks that would otherwise
be performed manually by a human. Of course, these "tasks" are essentially a
human giving instructions to a machine, as described above, so you could say that
a script instructs a machine on what instructions to give itself that a human
would otherwise give.
2
DEV SUMMIT 2017 EXTENDED
Agenda
1. Python Installation
2. Syntax
3. Objects
4. Conditions and Loops
5. Classes and Functions
6. Error Handling
7. Modules
8. Working with Files
9. Working With database
3
DEV SUMMIT 2017 EXTENDED
Python Installation
• Perquisites on windows.
• Download python for windows
https://www.python.org/downloads/windows/
• For this session we will use 3.6.0
• Download python for mac (for latest Update)
https://www.python.org/downloads/mac-osx/
• In Mac and Lunix its installed by default
• To run python use CMD -> Python
• Editors such as Pycharm , eclipse + pydev, Sublime, Aptana
4
DEV SUMMIT 2017 EXTENDED
Everything is an Object
• Id, type, value
• Id is unique identifier for the object
• Type is the class it is initialized from
• Value is the content
5
DEV SUMMIT 2017 EXTENDED
Syntax
• Python doesn’t use “int, double, string, var, etc…” as variable type.
Instead, python creates everything as an object and based on
assignment it calls the class and initialize
• Python doesn’t use “;”. It depends on whitespaces and indentation.
Wrong indentation means buggy code. P.S: you either use
whitespaces or tab.
• Example
• A = 0
• a,b,c = 0,1,”Hello”
6
DEV SUMMIT 2017 EXTENDED
Syntax Mutable vs immutable
• Number , Strings, Tuples are immutable.
• List , Dictionaries , other objects depending upon implementation.
7
DEV SUMMIT 2017 EXTENDED
Syntax
• When changing a value of an Immutable object. the reference of
value changes.
• Example
x=2
Id(x)
>>> 1231312
x=3
Id(x)
>>> 2349233
x=2
Id(x)
>>> 1231312
8
DEV SUMMIT 2017 EXTENDED
Syntax
• The variables created are stored in ram for later garbage collection to
pick it up. However there is a “faster” way using “del” keyword to
delete that variable
9
DEV SUMMIT 2017 EXTENDED
Syntax
• However, we can figure out the type of object with 2 ways.
1- the value
2- type(x) <- this will print out <class ‘str’>
a. it can be used to if want to make sure that the values are of certain type.
Note that print by default adds new line, it can be manipulated using
print (‘----’, end=‘’) <- end here will add zero space instead of newline
10
DEV SUMMIT 2017 EXTENDED
Syntax Dealing with Strings
• Strings can be used for chars and strings.
• Using single-quoted or double quoted is the same
• Since there is no char support, the work around is substring.
var1 = ‘hello world’
var2 = ‘python programming’
print(var1[0]) -> h
print(var2[8:]) -> programming
0 1 2 3 4
H E L L O
-5 -4 -3 -2 -1
11
DEV SUMMIT 2017 EXTENDED
Syntax Dealing with Strings
• r’string writenn here’ will result in string writenn here
• ‘String writenn here’ ->
• ‘My name is {} ‘. Format(“Mohamed hegazy”)
• My name is Mohamed hegazy
string write
n here
12
var = "hello World"
print(var[0]) # Single Char
print(var[5:]) # Range
print(var[:6]) # Range
print(var[:-1]) # Range
print("W" in var)
print('helntnn')
print(r'helntnn')
DEV SUMMIT 2017 EXTENDED
Syntax (*args and **kwargs)
• *Args prints data as tuple (remember tuple is immutable)
• **Kwargs prints and saves data as dictionary (remember dictionary is
mutable)
13
DEV SUMMIT 2017 EXTENDED
Conditions
• If condition doesn’t have “()”
Ex. If a<b:
print(‘a is bigger than b’)
• Python doesn’t support the switch statement, however there is a work
around.
If v == ‘----’:
Print(“this is first one”)
elif v == ‘qwdqwdqq’:
print(“this is the second one”)
else:
print(“this is not in the switch case”)
and, or, not
14
DEV SUMMIT 2017 EXTENDED
Loops
• While loop.
• For loop
For i = 0, i<x , i++ -> it doesn’t exist
15
while i < 10:
print(i)
i += i
for line in cursor.fetchall():
print(line, end=" ")
DEV SUMMIT 2017 EXTENDED
Defining Classes and functions
• Class is how to create your own object
• Class is a blueprint for an object
• Object is instance of a class
• Classes can be used in inheritance
16
DEV SUMMIT 2017 EXTENDED
Defining Classes
17
DEV SUMMIT 2017 EXTENDED
Defining Classes
18
if __name__ == '__main__':main()
DEV SUMMIT 2017 EXTENDED
Error Handling
• Python error handling, Mitigating the app from crashing on error.
• Raising Exception
• Raise is used to create custom exceptions
• Ex. Have a .docx file and .txt file. Mainly, my data is stored in .txt file,
therefore I created a custom exception to notify the user to only use. Txt file
19
DEV SUMMIT 2017 EXTENDED
Error Handling
20
DEV SUMMIT 2017 EXTENDED
Power of Yield
• Yield is like the return . However, yield can be used to return the
argument and continue the loop
• def __iter__(self):
i = self.start
while(i <= self.stop):
yield i
i += self.step
21
DEV SUMMIT 2017 EXTENDED
modules
• Modules are used to add “extension/inheritance” .
• Basic Python support limited functions comparing to modules.
• Using PIP and Easy_install
• Ex. Adding web functionality to python .
• Import Django
• Import sqlite3
Ex.
Import Django .
Django.Version
pinrt(Django.get_version())
22
DEV SUMMIT 2017 EXTENDED
File I/O
• Read from file
• Write to file
• Read from file binary
• Write to file binary
• Buffer read , Buffer write
• appending
23
DEV SUMMIT 2017 EXTENDED
File I/O
24
DEV SUMMIT 2017 EXTENDED
Database
• CRUD Operation IN Python combining it with try/catch , class,
functions.
25
DEV SUMMIT 2017 EXTENDED
Database
26
DEV SUMMIT 2017 EXTENDED
Database
27
DEV SUMMIT 2017 EXTENDED
Database
28
DEV SUMMIT 2017 EXTENDED
Concepts of BigData
Mohamed Hegazy
DEV SUMMIT 2017 EXTENDED
Agenda
• Introduction
• What is Big Data
• Concepts of Big Data
• Google Big Data Tools
• BigQuery
• Cloud Dataflow
• Cloud Dataproc
• Cloud Datalab
• Cloud Dataprep
• Cloud Pub/Sub
• Genomics
• Google Data Studio
DEV SUMMIT 2017 EXTENDED
What is Big Data
• extremely large data sets that may be analyzed computationally to
reveal patterns, trends, and associations, especially relating to human
behavior and interactions.
• 90% of World Data Generated in the last 2 Years (May 2013)
• Huge Volume
• Super speed Velocity
• Uncountable Variety
DEV SUMMIT 2017 EXTENDED
What is Big Data
• Facebook Handles 40 Billion Photos from its users
• Facebook Handles 500 TB of new data every day
• Walmart Handles 1 Billion Transactions per hour
• IOT
• etc
DEV SUMMIT 2017 EXTENDED
What is Big Data
DEV SUMMIT 2017 EXTENDED
Concepts of Big Data
• Volume. Organizations collect data from a variety of sources,
including business transactions, social media and information from
sensor or machine-to-machine data. In the past, storing it would’ve
been a problem – but new technologies (such as Hadoop) have eased
the burden.
• Velocity. Data streams in at an unprecedented speed and must be
dealt with in a timely manner. RFID tags, sensors and smart metering
are driving the need to deal with torrents of data in near-real time.
• Variety. Data comes in all types of formats – from structured, numeric
data in traditional databases to unstructured text documents, email,
video, audio, stock ticker data and financial transactions.
DEV SUMMIT 2017 EXTENDED
Concepts of Big Data
• Size of the internet (estimate) 1061677 Petabytes Doubles Every 2
years – excluding the Deep Web
• Data could be structured (SQL)
• Data could be semi- structured (CSV, NoSQL)
• Data could be un-structured ( e-mail messages, word processing
documents, videos, photos, audio files, presentations, webpages and
many other )
DEV SUMMIT 2017 EXTENDED
Concepts of Big Data
• Machine Generated unstructured data:
• Satellite images
• Scientific data
• Photos and videos
• Radars and sensors
• Human Generated unstructured data:
• Text internal to your company
• Social media data
• Mobile data
• Website content
DEV SUMMIT 2017 EXTENDED
Big Query
• BigQuery is Google's fully managed, petabyte scale, low cost
enterprise data warehouse for analytics. BigQuery
is serverless. There is no infrastructure to manage and you don't need
a database administrator, so you can focus on analyzing data to find
meaningful insights using familiar SQL. BigQuery is a powerful Big
Data analytics platform used by all types of organizations, from
startups to Fortune 500 companies.
DEV SUMMIT 2017 EXTENDED
Big Query
DEV SUMMIT 2017 EXTENDED
Cloud Dataflow
• Dataflow is a unified programming model and a managed service for
developing and executing a wide range of data processing patterns
including ETL, batch computation, and continuous computation.
Cloud Dataflow frees you from operational tasks like resource
management and performance optimization.
•
DEV SUMMIT 2017 EXTENDED
Cloud Dataflow
DEV SUMMIT 2017 EXTENDED
Cloud Dataproc
• Use Google Cloud Dataproc, an Apache Hadoop, Apache
Spark, Apache Pig, andApache Hive service, to easily process big
datasets at low cost. Control your costs by quickly creating managed
clusters of any size and turning them off when you're done. Cloud
Dataproc integrates across Google Cloud Platform products, giving
you a powerful and complete data processing platform.
•
DEV SUMMIT 2017 EXTENDED
Cloud Dataproc
DEV SUMMIT 2017 EXTENDED
Cloud Dataproc
DEV SUMMIT 2017 EXTENDED
Cloud Dataprep
• Google Cloud Dataprep is an intelligent data service for visually
exploring, cleaning, and preparing structured and unstructured data
for analysis. Cloud Dataprep is serverless and works at any scale.
There is no infrastructure to deploy or manage. Easy data preparation
with clicks and no code.
DEV SUMMIT 2017 EXTENDED
Cloud Dataprep
DEV SUMMIT 2017 EXTENDED
Cloud Pub/Sub
• Reliable, async, topic-based message service
• Many to many
• a scalable messaging middleware service in the cloud that allows
developers to quickly pass information between applications, no
matter where they’re hosted.
DEV SUMMIT 2017 EXTENDED
Cloud Pub/Sub
DEV SUMMIT 2017 EXTENDED
Cloud Datalab
• Cloud Datalab is a powerful interactive tool created to explore,
analyze, transform and visualize data and build machine learning
models on Google Cloud Platform. It runs on Google Compute
Engine and connects to multiple cloud services easily so you can focus
on your data science tasks.
• Go from data to deployed machine-learning (ML) models ready for
prediction. Explore data, build, evaluate and optimize Machine
Learning models using TensorFlow orCloud Machine Learning Engine.
DEV SUMMIT 2017 EXTENDED
Cloud Datalab
DEV SUMMIT 2017 EXTENDED
Genomics
• Google Genomics helps the life science community organize the
world’s genomic information and make it accessible and useful. Big
genomic data is here today, with petabytes rapidly growing toward
exabytes. Through our extensions to Google Cloud Platform, you can
apply the same technologies that power Google Search and Maps to
securely store, process, explore, and share large, complex datasets.
DEV SUMMIT 2017 EXTENDED
GOOGLE Data Studio (beta)
• Google Data Studio turns your data into informative dashboards and
reports that are easy to read, easy to share, and fully customizable.
Dashboarding allows you to tell great data stories to support better
business decisions.
• https://datastudio.google.com/u/0/org//reporting/0B_U5RNpwhcE6
TmpwV2hBOGdKYWM/page/qlD
DEV SUMMIT 2017 EXTENDED
Refrence
• https://blogs.sap.com/2015/01/20/why-airlines-need-to-keep-
planes-in-the-air/
• https://www.slideshare.net/nasrinhussain1/big-data-ppt-31616290
• https://jeremyronk.wordpress.com/2014/09/01/structured-semi-
structured-and-unstructured-data/
• https://cloud.google.com/data-studio/
DEV SUMMIT 2017 EXTENDED
Thank You For Attending
Any Questions ?
53

More Related Content

What's hot

Overview of python 2019
Overview of python 2019Overview of python 2019
Overview of python 2019
Samir Mohanty
 
Programming with Python
Programming with PythonProgramming with Python
Programming with Python
Rasan Samarasinghe
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
Agung Wahyudi
 
Programming
ProgrammingProgramming
Programming
monishagoyal4
 
Python Programming
Python ProgrammingPython Programming
Python Programming
Saravanan T.M
 
Basic Python Programming: Part 01 and Part 02
Basic Python Programming: Part 01 and Part 02Basic Python Programming: Part 01 and Part 02
Basic Python Programming: Part 01 and Part 02
Fariz Darari
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
AnirudhaGaikwad4
 
Beginning Python Programming
Beginning Python ProgrammingBeginning Python Programming
Beginning Python Programming
St. Petersburg College
 
Python basic
Python basicPython basic
Python basic
Saifuddin Kaijar
 
Python final ppt
Python final pptPython final ppt
Python final ppt
Ripal Ranpara
 
Introduction to python programming
Introduction to python programmingIntroduction to python programming
Introduction to python programming
Srinivas Narasegouda
 
Benefits & features of python |Advantages & disadvantages of python
Benefits & features of python |Advantages & disadvantages of pythonBenefits & features of python |Advantages & disadvantages of python
Benefits & features of python |Advantages & disadvantages of python
paradisetechsoftsolutions
 
Introduction to python programming, Why Python?, Applications of Python
Introduction to python programming, Why Python?, Applications of PythonIntroduction to python programming, Why Python?, Applications of Python
Introduction to python programming, Why Python?, Applications of Python
Pro Guide
 
Python basics
Python basicsPython basics
Python basics
Jyoti shukla
 
Python programming
Python  programmingPython  programming
Python programming
Ashwin Kumar Ramasamy
 
Python basics
Python basicsPython basics
Python basics
RANAALIMAJEEDRAJPUT
 
Basics of python
Basics of pythonBasics of python
Basics of python
Jatin Kochhar
 
Python Programming ppt
Python Programming pptPython Programming ppt
Python Programming ppt
ismailmrribi
 

What's hot (20)

Overview of python 2019
Overview of python 2019Overview of python 2019
Overview of python 2019
 
Programming with Python
Programming with PythonProgramming with Python
Programming with Python
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Programming
ProgrammingProgramming
Programming
 
Python Tutorial Part 2
Python Tutorial Part 2Python Tutorial Part 2
Python Tutorial Part 2
 
Python Programming
Python ProgrammingPython Programming
Python Programming
 
Basic Python Programming: Part 01 and Part 02
Basic Python Programming: Part 01 and Part 02Basic Python Programming: Part 01 and Part 02
Basic Python Programming: Part 01 and Part 02
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Beginning Python Programming
Beginning Python ProgrammingBeginning Python Programming
Beginning Python Programming
 
Python basic
Python basicPython basic
Python basic
 
Python final ppt
Python final pptPython final ppt
Python final ppt
 
Python Tutorial Part 1
Python Tutorial Part 1Python Tutorial Part 1
Python Tutorial Part 1
 
Introduction to python programming
Introduction to python programmingIntroduction to python programming
Introduction to python programming
 
Benefits & features of python |Advantages & disadvantages of python
Benefits & features of python |Advantages & disadvantages of pythonBenefits & features of python |Advantages & disadvantages of python
Benefits & features of python |Advantages & disadvantages of python
 
Introduction to python programming, Why Python?, Applications of Python
Introduction to python programming, Why Python?, Applications of PythonIntroduction to python programming, Why Python?, Applications of Python
Introduction to python programming, Why Python?, Applications of Python
 
Python basics
Python basicsPython basics
Python basics
 
Python programming
Python  programmingPython  programming
Python programming
 
Python basics
Python basicsPython basics
Python basics
 
Basics of python
Basics of pythonBasics of python
Basics of python
 
Python Programming ppt
Python Programming pptPython Programming ppt
Python Programming ppt
 

Similar to GDG Helwan Introduction to python

Intro to Python
Intro to PythonIntro to Python
Toolboxes for data scientists
Toolboxes for data scientistsToolboxes for data scientists
Toolboxes for data scientists
Sudipto Krishna Dutta
 
Software Engineering
Software EngineeringSoftware Engineering
Software Engineering
Tharindu Weerasinghe
 
.NET per la Data Science e oltre
.NET per la Data Science e oltre.NET per la Data Science e oltre
.NET per la Data Science e oltre
Marco Parenzan
 
Python with dataScience
Python with dataSciencePython with dataScience
Big Data Analytics (ML, DL, AI) hands-on
Big Data Analytics (ML, DL, AI) hands-onBig Data Analytics (ML, DL, AI) hands-on
Big Data Analytics (ML, DL, AI) hands-on
Dony Riyanto
 
TeelTech - Advancing Mobile Device Forensics (online version)
TeelTech - Advancing Mobile Device Forensics (online version)TeelTech - Advancing Mobile Device Forensics (online version)
TeelTech - Advancing Mobile Device Forensics (online version)Mike Felch
 
Webinar: Scaling MongoDB
Webinar: Scaling MongoDBWebinar: Scaling MongoDB
Webinar: Scaling MongoDB
MongoDB
 
DevOps for Data Engineers - Automate Your Data Science Pipeline with Ansible,...
DevOps for Data Engineers - Automate Your Data Science Pipeline with Ansible,...DevOps for Data Engineers - Automate Your Data Science Pipeline with Ansible,...
DevOps for Data Engineers - Automate Your Data Science Pipeline with Ansible,...
Mihai Criveti
 
Python
PythonPython
Raising the Bar
Raising the BarRaising the Bar
Raising the Bar
Alexandru Bolboaca
 
Makine Öğrenmesi, Yapay Zeka ve Veri Bilimi Süreçlerinin Otomatikleştirilmesi...
Makine Öğrenmesi, Yapay Zeka ve Veri Bilimi Süreçlerinin Otomatikleştirilmesi...Makine Öğrenmesi, Yapay Zeka ve Veri Bilimi Süreçlerinin Otomatikleştirilmesi...
Makine Öğrenmesi, Yapay Zeka ve Veri Bilimi Süreçlerinin Otomatikleştirilmesi...
Ali Alkan
 
Machine Learning
Machine LearningMachine Learning
Machine Learning
Ramiro Aduviri Velasco
 
Machine Learning with ML.NET and Azure - Andy Cross
Machine Learning with ML.NET and Azure - Andy CrossMachine Learning with ML.NET and Azure - Andy Cross
Machine Learning with ML.NET and Azure - Andy Cross
Andrew Flatters
 
Kelly O'Briant - DataOps in the Cloud: How To Supercharge Data Science with a...
Kelly O'Briant - DataOps in the Cloud: How To Supercharge Data Science with a...Kelly O'Briant - DataOps in the Cloud: How To Supercharge Data Science with a...
Kelly O'Briant - DataOps in the Cloud: How To Supercharge Data Science with a...
Rehgan Avon
 
Continuum Analytics and Python
Continuum Analytics and PythonContinuum Analytics and Python
Continuum Analytics and Python
Travis Oliphant
 
Are API Services Taking Over All the Interesting Data Science Problems?
Are API Services Taking Over All the Interesting Data Science Problems?Are API Services Taking Over All the Interesting Data Science Problems?
Are API Services Taking Over All the Interesting Data Science Problems?
IDEAS - Int'l Data Engineering and Science Association
 
From a student to an apache committer practice of apache io tdb
From a student to an apache committer  practice of apache io tdbFrom a student to an apache committer  practice of apache io tdb
From a student to an apache committer practice of apache io tdb
jixuan1989
 
Abhishek Training PPT.pptx
Abhishek Training PPT.pptxAbhishek Training PPT.pptx
Abhishek Training PPT.pptx
KashishKashish22
 

Similar to GDG Helwan Introduction to python (20)

Intro to Python
Intro to PythonIntro to Python
Intro to Python
 
Toolboxes for data scientists
Toolboxes for data scientistsToolboxes for data scientists
Toolboxes for data scientists
 
Software Engineering
Software EngineeringSoftware Engineering
Software Engineering
 
.NET per la Data Science e oltre
.NET per la Data Science e oltre.NET per la Data Science e oltre
.NET per la Data Science e oltre
 
Python with dataScience
Python with dataSciencePython with dataScience
Python with dataScience
 
Big Data Analytics (ML, DL, AI) hands-on
Big Data Analytics (ML, DL, AI) hands-onBig Data Analytics (ML, DL, AI) hands-on
Big Data Analytics (ML, DL, AI) hands-on
 
TeelTech - Advancing Mobile Device Forensics (online version)
TeelTech - Advancing Mobile Device Forensics (online version)TeelTech - Advancing Mobile Device Forensics (online version)
TeelTech - Advancing Mobile Device Forensics (online version)
 
Webinar: Scaling MongoDB
Webinar: Scaling MongoDBWebinar: Scaling MongoDB
Webinar: Scaling MongoDB
 
DevOps for Data Engineers - Automate Your Data Science Pipeline with Ansible,...
DevOps for Data Engineers - Automate Your Data Science Pipeline with Ansible,...DevOps for Data Engineers - Automate Your Data Science Pipeline with Ansible,...
DevOps for Data Engineers - Automate Your Data Science Pipeline with Ansible,...
 
Python
PythonPython
Python
 
Raising the Bar
Raising the BarRaising the Bar
Raising the Bar
 
Makine Öğrenmesi, Yapay Zeka ve Veri Bilimi Süreçlerinin Otomatikleştirilmesi...
Makine Öğrenmesi, Yapay Zeka ve Veri Bilimi Süreçlerinin Otomatikleştirilmesi...Makine Öğrenmesi, Yapay Zeka ve Veri Bilimi Süreçlerinin Otomatikleştirilmesi...
Makine Öğrenmesi, Yapay Zeka ve Veri Bilimi Süreçlerinin Otomatikleştirilmesi...
 
Machine Learning
Machine LearningMachine Learning
Machine Learning
 
Bdd with m spec
Bdd with m specBdd with m spec
Bdd with m spec
 
Machine Learning with ML.NET and Azure - Andy Cross
Machine Learning with ML.NET and Azure - Andy CrossMachine Learning with ML.NET and Azure - Andy Cross
Machine Learning with ML.NET and Azure - Andy Cross
 
Kelly O'Briant - DataOps in the Cloud: How To Supercharge Data Science with a...
Kelly O'Briant - DataOps in the Cloud: How To Supercharge Data Science with a...Kelly O'Briant - DataOps in the Cloud: How To Supercharge Data Science with a...
Kelly O'Briant - DataOps in the Cloud: How To Supercharge Data Science with a...
 
Continuum Analytics and Python
Continuum Analytics and PythonContinuum Analytics and Python
Continuum Analytics and Python
 
Are API Services Taking Over All the Interesting Data Science Problems?
Are API Services Taking Over All the Interesting Data Science Problems?Are API Services Taking Over All the Interesting Data Science Problems?
Are API Services Taking Over All the Interesting Data Science Problems?
 
From a student to an apache committer practice of apache io tdb
From a student to an apache committer  practice of apache io tdbFrom a student to an apache committer  practice of apache io tdb
From a student to an apache committer practice of apache io tdb
 
Abhishek Training PPT.pptx
Abhishek Training PPT.pptxAbhishek Training PPT.pptx
Abhishek Training PPT.pptx
 

Recently uploaded

Bitcoin Lightning wallet and tic-tac-toe game XOXO
Bitcoin Lightning wallet and tic-tac-toe game XOXOBitcoin Lightning wallet and tic-tac-toe game XOXO
Bitcoin Lightning wallet and tic-tac-toe game XOXO
Matjaž Lipuš
 
somanykidsbutsofewfathers-140705000023-phpapp02.pptx
somanykidsbutsofewfathers-140705000023-phpapp02.pptxsomanykidsbutsofewfathers-140705000023-phpapp02.pptx
somanykidsbutsofewfathers-140705000023-phpapp02.pptx
Howard Spence
 
Announcement of 18th IEEE International Conference on Software Testing, Verif...
Announcement of 18th IEEE International Conference on Software Testing, Verif...Announcement of 18th IEEE International Conference on Software Testing, Verif...
Announcement of 18th IEEE International Conference on Software Testing, Verif...
Sebastiano Panichella
 
Eureka, I found it! - Special Libraries Association 2021 Presentation
Eureka, I found it! - Special Libraries Association 2021 PresentationEureka, I found it! - Special Libraries Association 2021 Presentation
Eureka, I found it! - Special Libraries Association 2021 Presentation
Access Innovations, Inc.
 
Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...
Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...
Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...
OECD Directorate for Financial and Enterprise Affairs
 
Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...
Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...
Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...
Orkestra
 
Getting started with Amazon Bedrock Studio and Control Tower
Getting started with Amazon Bedrock Studio and Control TowerGetting started with Amazon Bedrock Studio and Control Tower
Getting started with Amazon Bedrock Studio and Control Tower
Vladimir Samoylov
 
Obesity causes and management and associated medical conditions
Obesity causes and management and associated medical conditionsObesity causes and management and associated medical conditions
Obesity causes and management and associated medical conditions
Faculty of Medicine And Health Sciences
 
International Workshop on Artificial Intelligence in Software Testing
International Workshop on Artificial Intelligence in Software TestingInternational Workshop on Artificial Intelligence in Software Testing
International Workshop on Artificial Intelligence in Software Testing
Sebastiano Panichella
 
0x01 - Newton's Third Law: Static vs. Dynamic Abusers
0x01 - Newton's Third Law:  Static vs. Dynamic Abusers0x01 - Newton's Third Law:  Static vs. Dynamic Abusers
0x01 - Newton's Third Law: Static vs. Dynamic Abusers
OWASP Beja
 
Acorn Recovery: Restore IT infra within minutes
Acorn Recovery: Restore IT infra within minutesAcorn Recovery: Restore IT infra within minutes
Acorn Recovery: Restore IT infra within minutes
IP ServerOne
 
Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Doctoral Symposium at the 17th IEEE International Conference on Software Test...Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Sebastiano Panichella
 
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdfBonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
khadija278284
 

Recently uploaded (13)

Bitcoin Lightning wallet and tic-tac-toe game XOXO
Bitcoin Lightning wallet and tic-tac-toe game XOXOBitcoin Lightning wallet and tic-tac-toe game XOXO
Bitcoin Lightning wallet and tic-tac-toe game XOXO
 
somanykidsbutsofewfathers-140705000023-phpapp02.pptx
somanykidsbutsofewfathers-140705000023-phpapp02.pptxsomanykidsbutsofewfathers-140705000023-phpapp02.pptx
somanykidsbutsofewfathers-140705000023-phpapp02.pptx
 
Announcement of 18th IEEE International Conference on Software Testing, Verif...
Announcement of 18th IEEE International Conference on Software Testing, Verif...Announcement of 18th IEEE International Conference on Software Testing, Verif...
Announcement of 18th IEEE International Conference on Software Testing, Verif...
 
Eureka, I found it! - Special Libraries Association 2021 Presentation
Eureka, I found it! - Special Libraries Association 2021 PresentationEureka, I found it! - Special Libraries Association 2021 Presentation
Eureka, I found it! - Special Libraries Association 2021 Presentation
 
Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...
Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...
Competition and Regulation in Professional Services – KLEINER – June 2024 OEC...
 
Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...
Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...
Sharpen existing tools or get a new toolbox? Contemporary cluster initiatives...
 
Getting started with Amazon Bedrock Studio and Control Tower
Getting started with Amazon Bedrock Studio and Control TowerGetting started with Amazon Bedrock Studio and Control Tower
Getting started with Amazon Bedrock Studio and Control Tower
 
Obesity causes and management and associated medical conditions
Obesity causes and management and associated medical conditionsObesity causes and management and associated medical conditions
Obesity causes and management and associated medical conditions
 
International Workshop on Artificial Intelligence in Software Testing
International Workshop on Artificial Intelligence in Software TestingInternational Workshop on Artificial Intelligence in Software Testing
International Workshop on Artificial Intelligence in Software Testing
 
0x01 - Newton's Third Law: Static vs. Dynamic Abusers
0x01 - Newton's Third Law:  Static vs. Dynamic Abusers0x01 - Newton's Third Law:  Static vs. Dynamic Abusers
0x01 - Newton's Third Law: Static vs. Dynamic Abusers
 
Acorn Recovery: Restore IT infra within minutes
Acorn Recovery: Restore IT infra within minutesAcorn Recovery: Restore IT infra within minutes
Acorn Recovery: Restore IT infra within minutes
 
Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Doctoral Symposium at the 17th IEEE International Conference on Software Test...Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Doctoral Symposium at the 17th IEEE International Conference on Software Test...
 
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdfBonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
 

GDG Helwan Introduction to python

  • 1. DEV SUMMIT 2017 EXTENDED Introduction to Python 3 Mohamed Hegazy R&D Engineer .PY
  • 2. DEV SUMMIT 2017 EXTENDED What is python . WIKI • Python is a widely used high-level programming language used for general- purpose programming. An interpreted language, Python has a design philosophy which emphasizes code readability (notably using whitespace indentation to delimit code blocks rather than curly braces or keywords), and a syntax which allows programmers to express concepts in fewer lines of code than possible in languages such as C++ or Java.The language provides constructs intended to enable writing clear programs on both a small and large scale. • A scripting language is a subset of programming language that is used to produce scripts, which are sets of instructions that automate tasks that would otherwise be performed manually by a human. Of course, these "tasks" are essentially a human giving instructions to a machine, as described above, so you could say that a script instructs a machine on what instructions to give itself that a human would otherwise give. 2
  • 3. DEV SUMMIT 2017 EXTENDED Agenda 1. Python Installation 2. Syntax 3. Objects 4. Conditions and Loops 5. Classes and Functions 6. Error Handling 7. Modules 8. Working with Files 9. Working With database 3
  • 4. DEV SUMMIT 2017 EXTENDED Python Installation • Perquisites on windows. • Download python for windows https://www.python.org/downloads/windows/ • For this session we will use 3.6.0 • Download python for mac (for latest Update) https://www.python.org/downloads/mac-osx/ • In Mac and Lunix its installed by default • To run python use CMD -> Python • Editors such as Pycharm , eclipse + pydev, Sublime, Aptana 4
  • 5. DEV SUMMIT 2017 EXTENDED Everything is an Object • Id, type, value • Id is unique identifier for the object • Type is the class it is initialized from • Value is the content 5
  • 6. DEV SUMMIT 2017 EXTENDED Syntax • Python doesn’t use “int, double, string, var, etc…” as variable type. Instead, python creates everything as an object and based on assignment it calls the class and initialize • Python doesn’t use “;”. It depends on whitespaces and indentation. Wrong indentation means buggy code. P.S: you either use whitespaces or tab. • Example • A = 0 • a,b,c = 0,1,”Hello” 6
  • 7. DEV SUMMIT 2017 EXTENDED Syntax Mutable vs immutable • Number , Strings, Tuples are immutable. • List , Dictionaries , other objects depending upon implementation. 7
  • 8. DEV SUMMIT 2017 EXTENDED Syntax • When changing a value of an Immutable object. the reference of value changes. • Example x=2 Id(x) >>> 1231312 x=3 Id(x) >>> 2349233 x=2 Id(x) >>> 1231312 8
  • 9. DEV SUMMIT 2017 EXTENDED Syntax • The variables created are stored in ram for later garbage collection to pick it up. However there is a “faster” way using “del” keyword to delete that variable 9
  • 10. DEV SUMMIT 2017 EXTENDED Syntax • However, we can figure out the type of object with 2 ways. 1- the value 2- type(x) <- this will print out <class ‘str’> a. it can be used to if want to make sure that the values are of certain type. Note that print by default adds new line, it can be manipulated using print (‘----’, end=‘’) <- end here will add zero space instead of newline 10
  • 11. DEV SUMMIT 2017 EXTENDED Syntax Dealing with Strings • Strings can be used for chars and strings. • Using single-quoted or double quoted is the same • Since there is no char support, the work around is substring. var1 = ‘hello world’ var2 = ‘python programming’ print(var1[0]) -> h print(var2[8:]) -> programming 0 1 2 3 4 H E L L O -5 -4 -3 -2 -1 11
  • 12. DEV SUMMIT 2017 EXTENDED Syntax Dealing with Strings • r’string writenn here’ will result in string writenn here • ‘String writenn here’ -> • ‘My name is {} ‘. Format(“Mohamed hegazy”) • My name is Mohamed hegazy string write n here 12 var = "hello World" print(var[0]) # Single Char print(var[5:]) # Range print(var[:6]) # Range print(var[:-1]) # Range print("W" in var) print('helntnn') print(r'helntnn')
  • 13. DEV SUMMIT 2017 EXTENDED Syntax (*args and **kwargs) • *Args prints data as tuple (remember tuple is immutable) • **Kwargs prints and saves data as dictionary (remember dictionary is mutable) 13
  • 14. DEV SUMMIT 2017 EXTENDED Conditions • If condition doesn’t have “()” Ex. If a<b: print(‘a is bigger than b’) • Python doesn’t support the switch statement, however there is a work around. If v == ‘----’: Print(“this is first one”) elif v == ‘qwdqwdqq’: print(“this is the second one”) else: print(“this is not in the switch case”) and, or, not 14
  • 15. DEV SUMMIT 2017 EXTENDED Loops • While loop. • For loop For i = 0, i<x , i++ -> it doesn’t exist 15 while i < 10: print(i) i += i for line in cursor.fetchall(): print(line, end=" ")
  • 16. DEV SUMMIT 2017 EXTENDED Defining Classes and functions • Class is how to create your own object • Class is a blueprint for an object • Object is instance of a class • Classes can be used in inheritance 16
  • 17. DEV SUMMIT 2017 EXTENDED Defining Classes 17
  • 18. DEV SUMMIT 2017 EXTENDED Defining Classes 18 if __name__ == '__main__':main()
  • 19. DEV SUMMIT 2017 EXTENDED Error Handling • Python error handling, Mitigating the app from crashing on error. • Raising Exception • Raise is used to create custom exceptions • Ex. Have a .docx file and .txt file. Mainly, my data is stored in .txt file, therefore I created a custom exception to notify the user to only use. Txt file 19
  • 20. DEV SUMMIT 2017 EXTENDED Error Handling 20
  • 21. DEV SUMMIT 2017 EXTENDED Power of Yield • Yield is like the return . However, yield can be used to return the argument and continue the loop • def __iter__(self): i = self.start while(i <= self.stop): yield i i += self.step 21
  • 22. DEV SUMMIT 2017 EXTENDED modules • Modules are used to add “extension/inheritance” . • Basic Python support limited functions comparing to modules. • Using PIP and Easy_install • Ex. Adding web functionality to python . • Import Django • Import sqlite3 Ex. Import Django . Django.Version pinrt(Django.get_version()) 22
  • 23. DEV SUMMIT 2017 EXTENDED File I/O • Read from file • Write to file • Read from file binary • Write to file binary • Buffer read , Buffer write • appending 23
  • 24. DEV SUMMIT 2017 EXTENDED File I/O 24
  • 25. DEV SUMMIT 2017 EXTENDED Database • CRUD Operation IN Python combining it with try/catch , class, functions. 25
  • 26. DEV SUMMIT 2017 EXTENDED Database 26
  • 27. DEV SUMMIT 2017 EXTENDED Database 27
  • 28. DEV SUMMIT 2017 EXTENDED Database 28
  • 29. DEV SUMMIT 2017 EXTENDED Concepts of BigData Mohamed Hegazy
  • 30. DEV SUMMIT 2017 EXTENDED Agenda • Introduction • What is Big Data • Concepts of Big Data • Google Big Data Tools • BigQuery • Cloud Dataflow • Cloud Dataproc • Cloud Datalab • Cloud Dataprep • Cloud Pub/Sub • Genomics • Google Data Studio
  • 31. DEV SUMMIT 2017 EXTENDED What is Big Data • extremely large data sets that may be analyzed computationally to reveal patterns, trends, and associations, especially relating to human behavior and interactions. • 90% of World Data Generated in the last 2 Years (May 2013) • Huge Volume • Super speed Velocity • Uncountable Variety
  • 32. DEV SUMMIT 2017 EXTENDED What is Big Data • Facebook Handles 40 Billion Photos from its users • Facebook Handles 500 TB of new data every day • Walmart Handles 1 Billion Transactions per hour • IOT • etc
  • 33. DEV SUMMIT 2017 EXTENDED What is Big Data
  • 34. DEV SUMMIT 2017 EXTENDED Concepts of Big Data • Volume. Organizations collect data from a variety of sources, including business transactions, social media and information from sensor or machine-to-machine data. In the past, storing it would’ve been a problem – but new technologies (such as Hadoop) have eased the burden. • Velocity. Data streams in at an unprecedented speed and must be dealt with in a timely manner. RFID tags, sensors and smart metering are driving the need to deal with torrents of data in near-real time. • Variety. Data comes in all types of formats – from structured, numeric data in traditional databases to unstructured text documents, email, video, audio, stock ticker data and financial transactions.
  • 35. DEV SUMMIT 2017 EXTENDED Concepts of Big Data • Size of the internet (estimate) 1061677 Petabytes Doubles Every 2 years – excluding the Deep Web • Data could be structured (SQL) • Data could be semi- structured (CSV, NoSQL) • Data could be un-structured ( e-mail messages, word processing documents, videos, photos, audio files, presentations, webpages and many other )
  • 36. DEV SUMMIT 2017 EXTENDED Concepts of Big Data • Machine Generated unstructured data: • Satellite images • Scientific data • Photos and videos • Radars and sensors • Human Generated unstructured data: • Text internal to your company • Social media data • Mobile data • Website content
  • 37. DEV SUMMIT 2017 EXTENDED Big Query • BigQuery is Google's fully managed, petabyte scale, low cost enterprise data warehouse for analytics. BigQuery is serverless. There is no infrastructure to manage and you don't need a database administrator, so you can focus on analyzing data to find meaningful insights using familiar SQL. BigQuery is a powerful Big Data analytics platform used by all types of organizations, from startups to Fortune 500 companies.
  • 38. DEV SUMMIT 2017 EXTENDED Big Query
  • 39. DEV SUMMIT 2017 EXTENDED Cloud Dataflow • Dataflow is a unified programming model and a managed service for developing and executing a wide range of data processing patterns including ETL, batch computation, and continuous computation. Cloud Dataflow frees you from operational tasks like resource management and performance optimization. •
  • 40. DEV SUMMIT 2017 EXTENDED Cloud Dataflow
  • 41. DEV SUMMIT 2017 EXTENDED Cloud Dataproc • Use Google Cloud Dataproc, an Apache Hadoop, Apache Spark, Apache Pig, andApache Hive service, to easily process big datasets at low cost. Control your costs by quickly creating managed clusters of any size and turning them off when you're done. Cloud Dataproc integrates across Google Cloud Platform products, giving you a powerful and complete data processing platform. •
  • 42. DEV SUMMIT 2017 EXTENDED Cloud Dataproc
  • 43. DEV SUMMIT 2017 EXTENDED Cloud Dataproc
  • 44. DEV SUMMIT 2017 EXTENDED Cloud Dataprep • Google Cloud Dataprep is an intelligent data service for visually exploring, cleaning, and preparing structured and unstructured data for analysis. Cloud Dataprep is serverless and works at any scale. There is no infrastructure to deploy or manage. Easy data preparation with clicks and no code.
  • 45. DEV SUMMIT 2017 EXTENDED Cloud Dataprep
  • 46. DEV SUMMIT 2017 EXTENDED Cloud Pub/Sub • Reliable, async, topic-based message service • Many to many • a scalable messaging middleware service in the cloud that allows developers to quickly pass information between applications, no matter where they’re hosted.
  • 47. DEV SUMMIT 2017 EXTENDED Cloud Pub/Sub
  • 48. DEV SUMMIT 2017 EXTENDED Cloud Datalab • Cloud Datalab is a powerful interactive tool created to explore, analyze, transform and visualize data and build machine learning models on Google Cloud Platform. It runs on Google Compute Engine and connects to multiple cloud services easily so you can focus on your data science tasks. • Go from data to deployed machine-learning (ML) models ready for prediction. Explore data, build, evaluate and optimize Machine Learning models using TensorFlow orCloud Machine Learning Engine.
  • 49. DEV SUMMIT 2017 EXTENDED Cloud Datalab
  • 50. DEV SUMMIT 2017 EXTENDED Genomics • Google Genomics helps the life science community organize the world’s genomic information and make it accessible and useful. Big genomic data is here today, with petabytes rapidly growing toward exabytes. Through our extensions to Google Cloud Platform, you can apply the same technologies that power Google Search and Maps to securely store, process, explore, and share large, complex datasets.
  • 51. DEV SUMMIT 2017 EXTENDED GOOGLE Data Studio (beta) • Google Data Studio turns your data into informative dashboards and reports that are easy to read, easy to share, and fully customizable. Dashboarding allows you to tell great data stories to support better business decisions. • https://datastudio.google.com/u/0/org//reporting/0B_U5RNpwhcE6 TmpwV2hBOGdKYWM/page/qlD
  • 52. DEV SUMMIT 2017 EXTENDED Refrence • https://blogs.sap.com/2015/01/20/why-airlines-need-to-keep- planes-in-the-air/ • https://www.slideshare.net/nasrinhussain1/big-data-ppt-31616290 • https://jeremyronk.wordpress.com/2014/09/01/structured-semi- structured-and-unstructured-data/ • https://cloud.google.com/data-studio/
  • 53. DEV SUMMIT 2017 EXTENDED Thank You For Attending Any Questions ? 53