SlideShare a Scribd company logo
Examples in Python
 Python is a programming language with strengths of both functional and object-oriented 
programming. 
 Here I will present common problems and their solutions that you might use while 
starting coding in Python. 
 You may use this material as a reference. 
By Ashish Sharma for Next Craft
 One who has began learning Python. 
 One who has made oneself acquainted with concepts of Python taught in 
codecademy.com Python course. 
 One who wishes to learn the idioms of python to solve problems in pythonic way. 
 One who is interested in free, good content.  
By Ashish Sharma for Next Craft
 Learn by Doing: Here are examples of python code used in different scenarios. 
 You can try to pick the concepts and then mould them to use in your own 
situation. 
 Use of Classes, Exceptions, rest of Standard Library not covered here. 
By Ashish Sharma for Next Craft
 Let us suppose we have a file containing a student’s SGPAs from 8 semesters and 
we would like to write a new file with CGPA. 
 SGPA.txt , has list of numbers in different lines. 
 Generating CGPA.txt from SGPA.txt 
 We will first read the SGPA.txt file line by line, 
 Then accumulate the values into a single variable, 
 Then calculate CGPA value and write that back into a new file. 
Try out yourself with sample 
data 
By Ashish Sharma for Next Craft
Code 
By Ashish Sharma for Next Craft
 Let us suppose you have a list of SGPAs on scale of 10 and from it you want to 
calculate CGPA on scale of 4. 
 We will do this in two ways, 
 Using for loop, 
 Using map, reduce (they are not as scary as they may sound) 
 The ways of coding this by map, reduce etc. are less verbose and more 
transportable. 
By Ashish Sharma for Next Craft
Using for loop 
By Ashish Sharma for Next Craft
Using Reduce 
Using Map/Reduce 
By Ashish Sharma for Next Craft
 In Python the data structure of Map is implemented in Dictionary. 
 A map is a structure to store <key, value> relationships. 
 Suppose you need to compute sum of squares of given odd numbers that can not 
be smaller than 1 and larger than 99 
 In the example, we will pre compute as the limits are small and return answers 
from a dict. 
By Ashish Sharma for Next Craft
Code. 
By Ashish Sharma for Next Craft
 From the older sgpa example, if we wish to filter out the sgpa from list that were 
more than 8.5. 
 From the older odd_squares example, if we wish to filter out the odd squares 
where the number is a multiple of 3. 
By Ashish Sharma for Next Craft
 Here we will validate data sent our way with regular expressions. You can also use 
them for search, match and replace. 
 Suppose we want input from user to be a number, here is how to gracefully handle 
this requirement. 
By Ashish Sharma for Next Craft
 Unit testing is a very important aspect of software development. In Python, you 
can find extensive support for unit testing you code. 
 With unit testing we can test single functions, classes or whole modules. 
 Having code and test separately and testable is a prime software development 
requirement. 
 This fact is elicited in this advice that developers get from creator of Unit testing 
framework for Small talk, (one of the first or may be the first frameworks). 
 I recommend that developers spend 25-50% of their time developing tests. 
 Quoted from - http://www.xprogramming.com/testfram.htm 
By Ashish Sharma for Next Craft
 Here is a sample of code and test files. 
By Ashish Sharma for Next Craft
Please let me know in the comments if I am missing any general scenarios, which 
you would like to see in the examples here. 
I will be more than happy to extend this presentation. 
By Ashish Sharma for Next Craft
 Python Reference – The best guide on Python out there. 
 Codecademy – Beginner course on Python, totally free . 
 http://learnpythonthehardway.org/ - If you want to develop a deep sense of 
knowledge of Python, venture here. 
By Ashish Sharma for Next Craft
Find me at @ashish424242 and @kartaa. 
Checkout NextCraft’s JMP 
By Ashish Sharma for Next Craft

More Related Content

Viewers also liked

Lets learn Python !
Lets learn Python !Lets learn Python !
Lets learn Python !
Kiran Gangadharan
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
Nowell Strite
 
Python 4 Arc
Python 4 ArcPython 4 Arc
Python 4 Arc
absvis
 
The Python Programming Language and HDF5: H5Py
The Python Programming Language and HDF5: H5PyThe Python Programming Language and HDF5: H5Py
The Python Programming Language and HDF5: H5Py
The HDF-EOS Tools and Information Center
 
Python in real world.
Python in real world.Python in real world.
Python in real world.
Alph@.M
 
Substituting HDF5 tools with Python/H5py scripts
Substituting HDF5 tools with Python/H5py scriptsSubstituting HDF5 tools with Python/H5py scripts
Substituting HDF5 tools with Python/H5py scripts
The HDF-EOS Tools and Information Center
 
Introduction To Programming with Python-1
Introduction To Programming with Python-1Introduction To Programming with Python-1
Introduction To Programming with Python-1
Syed Farjad Zia Zaidi
 
Logic Over Language
Logic Over LanguageLogic Over Language
Logic Over Language
Purple, Rock, Scissors
 
Python and HDF5: Overview
Python and HDF5: OverviewPython and HDF5: Overview
Python and HDF5: Overview
andrewcollette
 
An Introduction to Interactive Programming in Python 2013
An Introduction to Interactive Programming in Python 2013An Introduction to Interactive Programming in Python 2013
An Introduction to Interactive Programming in Python 2013
Syed Farjad Zia Zaidi
 
Introduction to Databases
Introduction to DatabasesIntroduction to Databases
Introduction to Databases
Syed Farjad Zia Zaidi
 
Logic: Language and Information 1
Logic: Language and Information 1Logic: Language and Information 1
Logic: Language and Information 1
Syed Farjad Zia Zaidi
 
Introduction To Programming with Python-5
Introduction To Programming with Python-5Introduction To Programming with Python-5
Introduction To Programming with Python-5
Syed Farjad Zia Zaidi
 
Introduction To Programming with Python-4
Introduction To Programming with Python-4Introduction To Programming with Python-4
Introduction To Programming with Python-4
Syed Farjad Zia Zaidi
 
Introduction to UBI
Introduction to UBIIntroduction to UBI
Introduction to UBI
Roy Lee
 
Clase 2 estatica
Clase 2 estatica Clase 2 estatica
Clase 2 estatica
Gerald Moreira Ramírez
 
Python
PythonPython
Using HDF5 and Python: The H5py module
Using HDF5 and Python: The H5py moduleUsing HDF5 and Python: The H5py module
Using HDF5 and Python: The H5py module
The HDF-EOS Tools and Information Center
 
HDF5 Tools
HDF5 ToolsHDF5 Tools

Viewers also liked (19)

Lets learn Python !
Lets learn Python !Lets learn Python !
Lets learn Python !
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
 
Python 4 Arc
Python 4 ArcPython 4 Arc
Python 4 Arc
 
The Python Programming Language and HDF5: H5Py
The Python Programming Language and HDF5: H5PyThe Python Programming Language and HDF5: H5Py
The Python Programming Language and HDF5: H5Py
 
Python in real world.
Python in real world.Python in real world.
Python in real world.
 
Substituting HDF5 tools with Python/H5py scripts
Substituting HDF5 tools with Python/H5py scriptsSubstituting HDF5 tools with Python/H5py scripts
Substituting HDF5 tools with Python/H5py scripts
 
Introduction To Programming with Python-1
Introduction To Programming with Python-1Introduction To Programming with Python-1
Introduction To Programming with Python-1
 
Logic Over Language
Logic Over LanguageLogic Over Language
Logic Over Language
 
Python and HDF5: Overview
Python and HDF5: OverviewPython and HDF5: Overview
Python and HDF5: Overview
 
An Introduction to Interactive Programming in Python 2013
An Introduction to Interactive Programming in Python 2013An Introduction to Interactive Programming in Python 2013
An Introduction to Interactive Programming in Python 2013
 
Introduction to Databases
Introduction to DatabasesIntroduction to Databases
Introduction to Databases
 
Logic: Language and Information 1
Logic: Language and Information 1Logic: Language and Information 1
Logic: Language and Information 1
 
Introduction To Programming with Python-5
Introduction To Programming with Python-5Introduction To Programming with Python-5
Introduction To Programming with Python-5
 
Introduction To Programming with Python-4
Introduction To Programming with Python-4Introduction To Programming with Python-4
Introduction To Programming with Python-4
 
Introduction to UBI
Introduction to UBIIntroduction to UBI
Introduction to UBI
 
Clase 2 estatica
Clase 2 estatica Clase 2 estatica
Clase 2 estatica
 
Python
PythonPython
Python
 
Using HDF5 and Python: The H5py module
Using HDF5 and Python: The H5py moduleUsing HDF5 and Python: The H5py module
Using HDF5 and Python: The H5py module
 
HDF5 Tools
HDF5 ToolsHDF5 Tools
HDF5 Tools
 

Similar to Python programming - Everyday(ish) Examples

A gentle introduction to algorithm complexity analysis
A gentle introduction to algorithm complexity analysisA gentle introduction to algorithm complexity analysis
A gentle introduction to algorithm complexity analysis
Lewis Lin 🦊
 
علم البيانات - Data Sience
علم البيانات - Data Sience علم البيانات - Data Sience
علم البيانات - Data Sience
App Ttrainers .com
 
Mastering Python : 100+ Solved and Commented Exercises to Accelerate Your Lea...
Mastering Python : 100+ Solved and Commented Exercises to Accelerate Your Lea...Mastering Python : 100+ Solved and Commented Exercises to Accelerate Your Lea...
Mastering Python : 100+ Solved and Commented Exercises to Accelerate Your Lea...
Lucky Gods
 
Python 1&2.pptx
Python 1&2.pptxPython 1&2.pptx
Python 1&2.pptx
Chahbar1
 
Python 1&2.pptx
Python 1&2.pptxPython 1&2.pptx
Python 1&2.pptx
Chahbar1
 
Project
ProjectProject
Hasktut
HasktutHasktut
Hasktut
kv33
 
Howto argparse
Howto argparseHowto argparse
Howto argparse
Manuel Cueto
 
An Overview Of Java | Object Oriented Programming
An Overview Of Java | Object Oriented ProgrammingAn Overview Of Java | Object Oriented Programming
An Overview Of Java | Object Oriented Programming
ArghyaGayen1
 
First Steps in Python Programming
First Steps in Python ProgrammingFirst Steps in Python Programming
First Steps in Python Programming
Dozie Agbo
 
Explainability for Learning to Rank
Explainability for Learning to RankExplainability for Learning to Rank
Explainability for Learning to Rank
Sease
 
Top 10 Interview Questions for Coding Job.docx
Top 10 Interview Questions for Coding Job.docxTop 10 Interview Questions for Coding Job.docx
Top 10 Interview Questions for Coding Job.docx
Surendra Gusain
 
Top 10 Interview Questions for Coding Job.docx
Top 10 Interview Questions for Coding Job.docxTop 10 Interview Questions for Coding Job.docx
Top 10 Interview Questions for Coding Job.docx
Surendra Gusain
 
Sam python pro_points_slide
Sam python pro_points_slideSam python pro_points_slide
Sam python pro_points_slide
"Samprateek "Sam"" Sinha
 
Automation Testing theory notes.pptx
Automation Testing theory notes.pptxAutomation Testing theory notes.pptx
Automation Testing theory notes.pptx
NileshBorkar12
 
What is Range Function? | Range in Python Explained | Edureka
What is Range Function? | Range in Python Explained | EdurekaWhat is Range Function? | Range in Python Explained | Edureka
What is Range Function? | Range in Python Explained | Edureka
Edureka!
 
Python fundamentals
Python fundamentalsPython fundamentals
Python fundamentals
natnaelmamuye
 
Introduction on basic python and it's application
Introduction on basic python and it's applicationIntroduction on basic python and it's application
Introduction on basic python and it's application
sriram2110
 
Object-Oriented Programming Using C++
Object-Oriented Programming Using C++Object-Oriented Programming Using C++
Object-Oriented Programming Using C++
Salahaddin University-Erbil
 
Algorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to AlgorithmsAlgorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to Algorithms
Mohamed Loey
 

Similar to Python programming - Everyday(ish) Examples (20)

A gentle introduction to algorithm complexity analysis
A gentle introduction to algorithm complexity analysisA gentle introduction to algorithm complexity analysis
A gentle introduction to algorithm complexity analysis
 
علم البيانات - Data Sience
علم البيانات - Data Sience علم البيانات - Data Sience
علم البيانات - Data Sience
 
Mastering Python : 100+ Solved and Commented Exercises to Accelerate Your Lea...
Mastering Python : 100+ Solved and Commented Exercises to Accelerate Your Lea...Mastering Python : 100+ Solved and Commented Exercises to Accelerate Your Lea...
Mastering Python : 100+ Solved and Commented Exercises to Accelerate Your Lea...
 
Python 1&2.pptx
Python 1&2.pptxPython 1&2.pptx
Python 1&2.pptx
 
Python 1&2.pptx
Python 1&2.pptxPython 1&2.pptx
Python 1&2.pptx
 
Project
ProjectProject
Project
 
Hasktut
HasktutHasktut
Hasktut
 
Howto argparse
Howto argparseHowto argparse
Howto argparse
 
An Overview Of Java | Object Oriented Programming
An Overview Of Java | Object Oriented ProgrammingAn Overview Of Java | Object Oriented Programming
An Overview Of Java | Object Oriented Programming
 
First Steps in Python Programming
First Steps in Python ProgrammingFirst Steps in Python Programming
First Steps in Python Programming
 
Explainability for Learning to Rank
Explainability for Learning to RankExplainability for Learning to Rank
Explainability for Learning to Rank
 
Top 10 Interview Questions for Coding Job.docx
Top 10 Interview Questions for Coding Job.docxTop 10 Interview Questions for Coding Job.docx
Top 10 Interview Questions for Coding Job.docx
 
Top 10 Interview Questions for Coding Job.docx
Top 10 Interview Questions for Coding Job.docxTop 10 Interview Questions for Coding Job.docx
Top 10 Interview Questions for Coding Job.docx
 
Sam python pro_points_slide
Sam python pro_points_slideSam python pro_points_slide
Sam python pro_points_slide
 
Automation Testing theory notes.pptx
Automation Testing theory notes.pptxAutomation Testing theory notes.pptx
Automation Testing theory notes.pptx
 
What is Range Function? | Range in Python Explained | Edureka
What is Range Function? | Range in Python Explained | EdurekaWhat is Range Function? | Range in Python Explained | Edureka
What is Range Function? | Range in Python Explained | Edureka
 
Python fundamentals
Python fundamentalsPython fundamentals
Python fundamentals
 
Introduction on basic python and it's application
Introduction on basic python and it's applicationIntroduction on basic python and it's application
Introduction on basic python and it's application
 
Object-Oriented Programming Using C++
Object-Oriented Programming Using C++Object-Oriented Programming Using C++
Object-Oriented Programming Using C++
 
Algorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to AlgorithmsAlgorithms Lecture 1: Introduction to Algorithms
Algorithms Lecture 1: Introduction to Algorithms
 

Recently uploaded

Using Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query PerformanceUsing Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query Performance
Grant Fritchey
 
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise EditionWhy Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Envertis Software Solutions
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
timtebeek1
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
rodomar2
 
SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024
Hironori Washizaki
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
Rakesh Kumar R
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
Green Software Development
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
Philip Schwarz
 
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian CompaniesE-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
Quickdice ERP
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
Ayan Halder
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
Neo4j
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
Remote DBA Services
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
TheSMSPoint
 
What is Augmented Reality Image Tracking
What is Augmented Reality Image TrackingWhat is Augmented Reality Image Tracking
What is Augmented Reality Image Tracking
pavan998932
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
kalichargn70th171
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
Google
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
lorraineandreiamcidl
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
mz5nrf0n
 

Recently uploaded (20)

Using Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query PerformanceUsing Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query Performance
 
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise EditionWhy Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
Why Choose Odoo 17 Community & How it differs from Odoo 17 Enterprise Edition
 
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdfAutomated software refactoring with OpenRewrite and Generative AI.pptx.pdf
Automated software refactoring with OpenRewrite and Generative AI.pptx.pdf
 
OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024OpenMetadata Community Meeting - 5th June 2024
OpenMetadata Community Meeting - 5th June 2024
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
 
SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024SWEBOK and Education at FUSE Okinawa 2024
SWEBOK and Education at FUSE Okinawa 2024
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Fundamentals of Programming and Language Processors
Fundamentals of Programming and Language ProcessorsFundamentals of Programming and Language Processors
Fundamentals of Programming and Language Processors
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
 
Hand Rolled Applicative User Validation Code Kata
Hand Rolled Applicative User ValidationCode KataHand Rolled Applicative User ValidationCode Kata
Hand Rolled Applicative User Validation Code Kata
 
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian CompaniesE-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
 
GraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph TechnologyGraphSummit Paris - The art of the possible with Graph Technology
GraphSummit Paris - The art of the possible with Graph Technology
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
 
What is Augmented Reality Image Tracking
What is Augmented Reality Image TrackingWhat is Augmented Reality Image Tracking
What is Augmented Reality Image Tracking
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
 
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI AppAI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
AI Fusion Buddy Review: Brand New, Groundbreaking Gemini-Powered AI App
 
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOMLORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
LORRAINE ANDREI_LEQUIGAN_HOW TO USE ZOOM
 
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
原版定制美国纽约州立大学奥尔巴尼分校毕业证学位证书原版一模一样
 

Python programming - Everyday(ish) Examples

  • 2.  Python is a programming language with strengths of both functional and object-oriented programming.  Here I will present common problems and their solutions that you might use while starting coding in Python.  You may use this material as a reference. By Ashish Sharma for Next Craft
  • 3.  One who has began learning Python.  One who has made oneself acquainted with concepts of Python taught in codecademy.com Python course.  One who wishes to learn the idioms of python to solve problems in pythonic way.  One who is interested in free, good content.  By Ashish Sharma for Next Craft
  • 4.  Learn by Doing: Here are examples of python code used in different scenarios.  You can try to pick the concepts and then mould them to use in your own situation.  Use of Classes, Exceptions, rest of Standard Library not covered here. By Ashish Sharma for Next Craft
  • 5.  Let us suppose we have a file containing a student’s SGPAs from 8 semesters and we would like to write a new file with CGPA.  SGPA.txt , has list of numbers in different lines.  Generating CGPA.txt from SGPA.txt  We will first read the SGPA.txt file line by line,  Then accumulate the values into a single variable,  Then calculate CGPA value and write that back into a new file. Try out yourself with sample data By Ashish Sharma for Next Craft
  • 6. Code By Ashish Sharma for Next Craft
  • 7.  Let us suppose you have a list of SGPAs on scale of 10 and from it you want to calculate CGPA on scale of 4.  We will do this in two ways,  Using for loop,  Using map, reduce (they are not as scary as they may sound)  The ways of coding this by map, reduce etc. are less verbose and more transportable. By Ashish Sharma for Next Craft
  • 8. Using for loop By Ashish Sharma for Next Craft
  • 9. Using Reduce Using Map/Reduce By Ashish Sharma for Next Craft
  • 10.  In Python the data structure of Map is implemented in Dictionary.  A map is a structure to store <key, value> relationships.  Suppose you need to compute sum of squares of given odd numbers that can not be smaller than 1 and larger than 99  In the example, we will pre compute as the limits are small and return answers from a dict. By Ashish Sharma for Next Craft
  • 11. Code. By Ashish Sharma for Next Craft
  • 12.  From the older sgpa example, if we wish to filter out the sgpa from list that were more than 8.5.  From the older odd_squares example, if we wish to filter out the odd squares where the number is a multiple of 3. By Ashish Sharma for Next Craft
  • 13.  Here we will validate data sent our way with regular expressions. You can also use them for search, match and replace.  Suppose we want input from user to be a number, here is how to gracefully handle this requirement. By Ashish Sharma for Next Craft
  • 14.  Unit testing is a very important aspect of software development. In Python, you can find extensive support for unit testing you code.  With unit testing we can test single functions, classes or whole modules.  Having code and test separately and testable is a prime software development requirement.  This fact is elicited in this advice that developers get from creator of Unit testing framework for Small talk, (one of the first or may be the first frameworks).  I recommend that developers spend 25-50% of their time developing tests.  Quoted from - http://www.xprogramming.com/testfram.htm By Ashish Sharma for Next Craft
  • 15.  Here is a sample of code and test files. By Ashish Sharma for Next Craft
  • 16. Please let me know in the comments if I am missing any general scenarios, which you would like to see in the examples here. I will be more than happy to extend this presentation. By Ashish Sharma for Next Craft
  • 17.  Python Reference – The best guide on Python out there.  Codecademy – Beginner course on Python, totally free .  http://learnpythonthehardway.org/ - If you want to develop a deep sense of knowledge of Python, venture here. By Ashish Sharma for Next Craft
  • 18. Find me at @ashish424242 and @kartaa. Checkout NextCraft’s JMP By Ashish Sharma for Next Craft