SlideShare a Scribd company logo
1 of 32
Download to read offline
PYTHON FROM NOVICE TO 
NINJA. 
A CONVERT SESSION BY @ALSAYEDGAMAL
WARNING: BEGINNERS ONLY 
SESSION 
• Works also as a quick 
start guide for other 
language developers. 
• No offence Java guys :)
AGENDA 
• Motivation. 
• Python essentials. 
• Some basic examples. 
• What to hack ?
MOTIVATION 
WHY PYTHON ?
OPEN SOURCE 
(FREEDOM)
CROSS PLATFORM 
WRITE ONCE, RUN EVERYWHERE.
SYSTEM.OUT.PRINT(“HELLO,WORLD”); 
IT TAKES 1 LINE TO YOUR “HELLO, WORLD” 
EASY TO LEARN 
IT TAKES > 10 SECONDS TO WRITE YOUR 
HELLO, WORLD.
FROM 29TH TO 7TH IN < 8 YEARS* 
IT’S 8TH SINCE 2012 
*TOIBE.COM | TIOBE PROGRAMMING COMMUNITY INDEX FOR NOVEMBER 2014
PYTHON ESSENTIALS 
• Scripting nature. 
• Basic data types. 
• Operators. 
• Flow control. 
• Functions are fun. 
• Modules. 
• OOP.
EXPRESSION IN PYTHON. 
OPERATORS 
variable = 3 + 2 #EXPRESSION 
OPERANDS 
+ * = / % 
[] () > = 
& != | 
Variables 
x,name, 
__len__ 
Data 
5, “hello”, 
[1,2,3]
TYPES IN PYTHON 
#ASSIGNMENT 
! 
#CHECK FOO’S TYPE 
! 
#ANOTHER ASSIGNMENT 
! 
#FOO’S TYPE CHANGED 
variable = 10 
type(variable) 
variable = “ten” 
type(variable) 
Dynamic 
Implicit 
x = 10 + “10” #ERROR
TYPES IN PYTHON Strings 
line = “Hello” 
multi = “”” I use this to write multiline 
strings like html tags””” 
raw = r’I’ll not replace n or t’ #used in regex 
print(line[0]) #will print H try -3 
template = "%d developers founded %s” % (3, ‘GDG Mansoura’) 
#3 developers founded GDG Mansoura 
‘{0}, {1}, {2}’.format(‘A’, ‘B’, ‘C’) #A, B, C 
unicode_str = u’A unicode u018e string xf1'
TYPES IN PYTHON Boolean 
1. It’s True not true 
2. It’s False not false
TYPES IN PYTHON Data structures 
List 
names = [‘Ahmed’, ‘Sayed’, ‘AbdulHameed’] 
first_name = names[0] 
names[1] = “AlSayed” #names = [‘Ahmed’, ‘AlSayed’, ‘AbdulHameed’] 
Tuple 
family = (“AlSayed”, ”Reem”) 
family[1] = “Some one else” 
TypeError: 'tuple' object does not support item assignment 
x = 5 
y = 6 
x, y = y, x
TYPES IN PYTHON Data structures 
Dictionary 
phonebook = {‘name’:”Ahmed Gamal”, ‘age’ : 28, 
‘telephone’: ‘0123456789’,‘email’: ‘ahmed@example.com’} 
Traversing Dictionary 
for key in phonebook.keys(): print key 
for val in phonebook.values(): print val
PYTHON BLOCKS 
if condition: 
If block 
elif condition: 
else If block 
else: 
else block 
Branching 
Where is a fixed indentation spaces or tabs
PYTHON BLOCKS 
for item in xrange(10): 
for block 
else: 
@ normal end 
Loop 
while true: 
loop on this 
else: 
@ normal end 
Normal end means no break 
For is used basically for traversing iterable types (lists for example) 
xrange is generating an iterable object
PYTHON BLOCKS Loop 
found_obj = None 
for obj in objects: 
if obj.key == search_key: 
found_obj = obj 
break 
else: 
print (‘No object found.’)
PYTHON BLOCKS 
class Car(Vehicle): 
#constructor 
def __init__(self, arg1): 
pass 
Class Definition
PYTHON BLOCKS 
def foo(x,y): 
function body 
Functions 
def foo(x,y=‘default’): 
function body 
def foo(x,y=‘default’): 
function body 
def foo(x,y): 
return exprsn 
def foo(x,y=‘default’): 
function body 
def foo(x,y=‘default’): 
function body
GETTING YOUR HANDS DIRTY 
TIME TO EXPLAIN IN CODE.
BEFORE WE START 
• If you are linux or unix based you are good to go. 
• Else If you are on windows (I hope not) download 
and install 
• sublime text editor 
• python runtime 
• Our code will be perfect for Python 2.x and may be 
3.x.
SORTED?
MEDIA.PY 
P1: Tawfik Okasha 
P2: Amr Adib
SCRIPT HIGHLIGHTS. 
• Basic expression (variable assignment). 
• User input and output. 
• Function definition / passing function as variable. 
• List data-type. 
• Basic sorting.
MODULES AND PACKAGES 
• from foo import bar 
• from foor import * # please, don’t use it often 
• Packages are directory with __init__.py file 
• import this #Zen of python
NEXT: SHAPING YOUR EXPERIENCE 
SYSTEM ADMIN, WEB, DESKTOP, NETWORK, 
GAME DEVELOPMENT,…
QUESTIONS?
THANKS
RESOURCES 
• Google Education (Python Class)| 
https://developers.google.com/edu/python/ 
• Python Docs | https://docs.python.org 
• www.tiobe.com/index.php/content/paperinfo/ 
tpci/index.html

More Related Content

What's hot

Php 101 by David Menendez
Php 101 by David MenendezPhp 101 by David Menendez
Php 101 by David Menendezdm09f
 
Elegant Solutions For Everyday Python Problems - Nina Zakharenko
Elegant Solutions For Everyday Python Problems - Nina ZakharenkoElegant Solutions For Everyday Python Problems - Nina Zakharenko
Elegant Solutions For Everyday Python Problems - Nina ZakharenkoNina Zakharenko
 
PHP object calisthenics
PHP object calisthenicsPHP object calisthenics
PHP object calisthenicsGiorgio Cefaro
 
Total World Domination with i18n (es)
Total World Domination with i18n (es)Total World Domination with i18n (es)
Total World Domination with i18n (es)Zé Fontainhas
 
アプリを弄ってみる #1 #antama_ws
アプリを弄ってみる #1 #antama_wsアプリを弄ってみる #1 #antama_ws
アプリを弄ってみる #1 #antama_wsTakahiro Yoshimura
 
Type Systems & Props Design - Exploring PropTypes, TypeScript, Flow & Reason
Type Systems & Props Design - Exploring PropTypes, TypeScript, Flow & ReasonType Systems & Props Design - Exploring PropTypes, TypeScript, Flow & Reason
Type Systems & Props Design - Exploring PropTypes, TypeScript, Flow & ReasonNikolaus Graf
 
Perl6 operators and metaoperators
Perl6   operators and metaoperatorsPerl6   operators and metaoperators
Perl6 operators and metaoperatorsSimon Proctor
 
Advanced modulinos trial
Advanced modulinos trialAdvanced modulinos trial
Advanced modulinos trialbrian d foy
 
What is Python Lambda Function? Python Tutorial | Edureka
What is Python Lambda Function? Python Tutorial | EdurekaWhat is Python Lambda Function? Python Tutorial | Edureka
What is Python Lambda Function? Python Tutorial | EdurekaEdureka!
 
Advanced modulinos
Advanced modulinosAdvanced modulinos
Advanced modulinosbrian d foy
 
Python: with-statement, generators
Python: with-statement, generatorsPython: with-statement, generators
Python: with-statement, generatorsMario Konschake
 

What's hot (15)

Php 101 by David Menendez
Php 101 by David MenendezPhp 101 by David Menendez
Php 101 by David Menendez
 
Table through php
Table through phpTable through php
Table through php
 
Elegant Solutions For Everyday Python Problems - Nina Zakharenko
Elegant Solutions For Everyday Python Problems - Nina ZakharenkoElegant Solutions For Everyday Python Problems - Nina Zakharenko
Elegant Solutions For Everyday Python Problems - Nina Zakharenko
 
Dades i operadors
Dades i operadorsDades i operadors
Dades i operadors
 
PHP object calisthenics
PHP object calisthenicsPHP object calisthenics
PHP object calisthenics
 
Total World Domination with i18n (es)
Total World Domination with i18n (es)Total World Domination with i18n (es)
Total World Domination with i18n (es)
 
アプリを弄ってみる #1 #antama_ws
アプリを弄ってみる #1 #antama_wsアプリを弄ってみる #1 #antama_ws
アプリを弄ってみる #1 #antama_ws
 
Type Systems & Props Design - Exploring PropTypes, TypeScript, Flow & Reason
Type Systems & Props Design - Exploring PropTypes, TypeScript, Flow & ReasonType Systems & Props Design - Exploring PropTypes, TypeScript, Flow & Reason
Type Systems & Props Design - Exploring PropTypes, TypeScript, Flow & Reason
 
Perl6 operators and metaoperators
Perl6   operators and metaoperatorsPerl6   operators and metaoperators
Perl6 operators and metaoperators
 
Advanced modulinos trial
Advanced modulinos trialAdvanced modulinos trial
Advanced modulinos trial
 
What is Python Lambda Function? Python Tutorial | Edureka
What is Python Lambda Function? Python Tutorial | EdurekaWhat is Python Lambda Function? Python Tutorial | Edureka
What is Python Lambda Function? Python Tutorial | Edureka
 
Migrare da symfony 1 a Symfony2
 Migrare da symfony 1 a Symfony2  Migrare da symfony 1 a Symfony2
Migrare da symfony 1 a Symfony2
 
Php modul-2
Php modul-2Php modul-2
Php modul-2
 
Advanced modulinos
Advanced modulinosAdvanced modulinos
Advanced modulinos
 
Python: with-statement, generators
Python: with-statement, generatorsPython: with-statement, generators
Python: with-statement, generators
 

Similar to Python Novice to Ninja

Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...DRVaibhavmeshram1
 
An Intro to Python in 30 minutes
An Intro to Python in 30 minutesAn Intro to Python in 30 minutes
An Intro to Python in 30 minutesSumit Raj
 
Python for scientific computing
Python for scientific computingPython for scientific computing
Python for scientific computingGo Asgard
 
Python: an introduction for PHP webdevelopers
Python: an introduction for PHP webdevelopersPython: an introduction for PHP webdevelopers
Python: an introduction for PHP webdevelopersGlenn De Backer
 
Lesson1 python an introduction
Lesson1 python an introductionLesson1 python an introduction
Lesson1 python an introductionArulalan T
 
Python.pptx
Python.pptxPython.pptx
Python.pptxAshaS74
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to pythonAhmed Salama
 
Hands on Session on Python
Hands on Session on PythonHands on Session on Python
Hands on Session on PythonSumit Raj
 
From 0 to mine sweeper in pyside
From 0 to mine sweeper in pysideFrom 0 to mine sweeper in pyside
From 0 to mine sweeper in pysideDinesh Manajipet
 
Python introduction 2
Python introduction 2Python introduction 2
Python introduction 2Ahmad Hussein
 
Basic concept of Python.pptx includes design tool, identifier, variables.
Basic concept of Python.pptx includes design tool, identifier, variables.Basic concept of Python.pptx includes design tool, identifier, variables.
Basic concept of Python.pptx includes design tool, identifier, variables.supriyasarkar38
 
Drupal 8: A story of growing up and getting off the island
Drupal 8: A story of growing up and getting off the islandDrupal 8: A story of growing up and getting off the island
Drupal 8: A story of growing up and getting off the islandAngela Byron
 
The Ring programming language version 1.5.2 book - Part 6 of 181
The Ring programming language version 1.5.2 book - Part 6 of 181The Ring programming language version 1.5.2 book - Part 6 of 181
The Ring programming language version 1.5.2 book - Part 6 of 181Mahmoud Samir Fayed
 
Fast REST APIs Development with MongoDB
Fast REST APIs Development with MongoDBFast REST APIs Development with MongoDB
Fast REST APIs Development with MongoDBMongoDB
 
Functions, List and String methods
Functions, List and String methodsFunctions, List and String methods
Functions, List and String methodsPranavSB
 

Similar to Python Novice to Ninja (20)

Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
 
An Intro to Python in 30 minutes
An Intro to Python in 30 minutesAn Intro to Python in 30 minutes
An Intro to Python in 30 minutes
 
Python for scientific computing
Python for scientific computingPython for scientific computing
Python for scientific computing
 
Python: an introduction for PHP webdevelopers
Python: an introduction for PHP webdevelopersPython: an introduction for PHP webdevelopers
Python: an introduction for PHP webdevelopers
 
Lesson1 python an introduction
Lesson1 python an introductionLesson1 python an introduction
Lesson1 python an introduction
 
Python 101
Python 101Python 101
Python 101
 
Python.pptx
Python.pptxPython.pptx
Python.pptx
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Hands on Session on Python
Hands on Session on PythonHands on Session on Python
Hands on Session on Python
 
Python for dummies
Python for dummiesPython for dummies
Python for dummies
 
From 0 to mine sweeper in pyside
From 0 to mine sweeper in pysideFrom 0 to mine sweeper in pyside
From 0 to mine sweeper in pyside
 
Python introduction 2
Python introduction 2Python introduction 2
Python introduction 2
 
Python basic
Python basicPython basic
Python basic
 
обзор Python
обзор Pythonобзор Python
обзор Python
 
Basic concept of Python.pptx includes design tool, identifier, variables.
Basic concept of Python.pptx includes design tool, identifier, variables.Basic concept of Python.pptx includes design tool, identifier, variables.
Basic concept of Python.pptx includes design tool, identifier, variables.
 
Drupal 8: A story of growing up and getting off the island
Drupal 8: A story of growing up and getting off the islandDrupal 8: A story of growing up and getting off the island
Drupal 8: A story of growing up and getting off the island
 
Charming python
Charming pythonCharming python
Charming python
 
The Ring programming language version 1.5.2 book - Part 6 of 181
The Ring programming language version 1.5.2 book - Part 6 of 181The Ring programming language version 1.5.2 book - Part 6 of 181
The Ring programming language version 1.5.2 book - Part 6 of 181
 
Fast REST APIs Development with MongoDB
Fast REST APIs Development with MongoDBFast REST APIs Development with MongoDB
Fast REST APIs Development with MongoDB
 
Functions, List and String methods
Functions, List and String methodsFunctions, List and String methods
Functions, List and String methods
 

More from Al Sayed Gamal

More from Al Sayed Gamal (20)

9 patterns of microservices
9 patterns of microservices9 patterns of microservices
9 patterns of microservices
 
Elixir introduction
Elixir introductionElixir introduction
Elixir introduction
 
Racist syndrome (composition over inheritance)
Racist syndrome (composition over inheritance)Racist syndrome (composition over inheritance)
Racist syndrome (composition over inheritance)
 
Ionic Hybrid Mobile Application
Ionic Hybrid Mobile ApplicationIonic Hybrid Mobile Application
Ionic Hybrid Mobile Application
 
Rails course day 8
Rails course day 8Rails course day 8
Rails course day 8
 
Rails course day 7
Rails course day 7Rails course day 7
Rails course day 7
 
Rails course day 6
Rails course day 6Rails course day 6
Rails course day 6
 
Rails course day 5
Rails course day 5Rails course day 5
Rails course day 5
 
Rails course day 4
Rails course day 4Rails course day 4
Rails course day 4
 
Rails course day 3
Rails course day 3Rails course day 3
Rails course day 3
 
Rails course day 2
Rails course  day 2Rails course  day 2
Rails course day 2
 
Rails01
Rails01Rails01
Rails01
 
OpenStack Murano Application Catalog
OpenStack Murano Application CatalogOpenStack Murano Application Catalog
OpenStack Murano Application Catalog
 
Failfast
FailfastFailfast
Failfast
 
Git workshop
Git workshopGit workshop
Git workshop
 
Web development Hackathon
Web development HackathonWeb development Hackathon
Web development Hackathon
 
Python novice to ninja
Python novice to ninjaPython novice to ninja
Python novice to ninja
 
Python 45 minutes hangout #3
Python 45 minutes hangout #3Python 45 minutes hangout #3
Python 45 minutes hangout #3
 
Python 45 minutes Hangouts #4
Python 45 minutes Hangouts  #4Python 45 minutes Hangouts  #4
Python 45 minutes Hangouts #4
 
Python45 2
Python45 2Python45 2
Python45 2
 

Recently uploaded

Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 

Recently uploaded (20)

Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 

Python Novice to Ninja

  • 1.
  • 2. PYTHON FROM NOVICE TO NINJA. A CONVERT SESSION BY @ALSAYEDGAMAL
  • 3. WARNING: BEGINNERS ONLY SESSION • Works also as a quick start guide for other language developers. • No offence Java guys :)
  • 4. AGENDA • Motivation. • Python essentials. • Some basic examples. • What to hack ?
  • 7. CROSS PLATFORM WRITE ONCE, RUN EVERYWHERE.
  • 8. SYSTEM.OUT.PRINT(“HELLO,WORLD”); IT TAKES 1 LINE TO YOUR “HELLO, WORLD” EASY TO LEARN IT TAKES > 10 SECONDS TO WRITE YOUR HELLO, WORLD.
  • 9. FROM 29TH TO 7TH IN < 8 YEARS* IT’S 8TH SINCE 2012 *TOIBE.COM | TIOBE PROGRAMMING COMMUNITY INDEX FOR NOVEMBER 2014
  • 10. PYTHON ESSENTIALS • Scripting nature. • Basic data types. • Operators. • Flow control. • Functions are fun. • Modules. • OOP.
  • 11. EXPRESSION IN PYTHON. OPERATORS variable = 3 + 2 #EXPRESSION OPERANDS + * = / % [] () > = & != | Variables x,name, __len__ Data 5, “hello”, [1,2,3]
  • 12. TYPES IN PYTHON #ASSIGNMENT ! #CHECK FOO’S TYPE ! #ANOTHER ASSIGNMENT ! #FOO’S TYPE CHANGED variable = 10 type(variable) variable = “ten” type(variable) Dynamic Implicit x = 10 + “10” #ERROR
  • 13. TYPES IN PYTHON Strings line = “Hello” multi = “”” I use this to write multiline strings like html tags””” raw = r’I’ll not replace n or t’ #used in regex print(line[0]) #will print H try -3 template = "%d developers founded %s” % (3, ‘GDG Mansoura’) #3 developers founded GDG Mansoura ‘{0}, {1}, {2}’.format(‘A’, ‘B’, ‘C’) #A, B, C unicode_str = u’A unicode u018e string xf1'
  • 14. TYPES IN PYTHON Boolean 1. It’s True not true 2. It’s False not false
  • 15. TYPES IN PYTHON Data structures List names = [‘Ahmed’, ‘Sayed’, ‘AbdulHameed’] first_name = names[0] names[1] = “AlSayed” #names = [‘Ahmed’, ‘AlSayed’, ‘AbdulHameed’] Tuple family = (“AlSayed”, ”Reem”) family[1] = “Some one else” TypeError: 'tuple' object does not support item assignment x = 5 y = 6 x, y = y, x
  • 16. TYPES IN PYTHON Data structures Dictionary phonebook = {‘name’:”Ahmed Gamal”, ‘age’ : 28, ‘telephone’: ‘0123456789’,‘email’: ‘ahmed@example.com’} Traversing Dictionary for key in phonebook.keys(): print key for val in phonebook.values(): print val
  • 17. PYTHON BLOCKS if condition: If block elif condition: else If block else: else block Branching Where is a fixed indentation spaces or tabs
  • 18. PYTHON BLOCKS for item in xrange(10): for block else: @ normal end Loop while true: loop on this else: @ normal end Normal end means no break For is used basically for traversing iterable types (lists for example) xrange is generating an iterable object
  • 19. PYTHON BLOCKS Loop found_obj = None for obj in objects: if obj.key == search_key: found_obj = obj break else: print (‘No object found.’)
  • 20. PYTHON BLOCKS class Car(Vehicle): #constructor def __init__(self, arg1): pass Class Definition
  • 21. PYTHON BLOCKS def foo(x,y): function body Functions def foo(x,y=‘default’): function body def foo(x,y=‘default’): function body def foo(x,y): return exprsn def foo(x,y=‘default’): function body def foo(x,y=‘default’): function body
  • 22. GETTING YOUR HANDS DIRTY TIME TO EXPLAIN IN CODE.
  • 23. BEFORE WE START • If you are linux or unix based you are good to go. • Else If you are on windows (I hope not) download and install • sublime text editor • python runtime • Our code will be perfect for Python 2.x and may be 3.x.
  • 25. MEDIA.PY P1: Tawfik Okasha P2: Amr Adib
  • 26. SCRIPT HIGHLIGHTS. • Basic expression (variable assignment). • User input and output. • Function definition / passing function as variable. • List data-type. • Basic sorting.
  • 27. MODULES AND PACKAGES • from foo import bar • from foor import * # please, don’t use it often • Packages are directory with __init__.py file • import this #Zen of python
  • 28. NEXT: SHAPING YOUR EXPERIENCE SYSTEM ADMIN, WEB, DESKTOP, NETWORK, GAME DEVELOPMENT,…
  • 29.
  • 32. RESOURCES • Google Education (Python Class)| https://developers.google.com/edu/python/ • Python Docs | https://docs.python.org • www.tiobe.com/index.php/content/paperinfo/ tpci/index.html