SlideShare a Scribd company logo
1 of 19
Presented by: Prithwish Chakraborty
LET’S CODE!!!
Sponsored by: AKAMAI
Reference: http://www.tutorialspoint.com/python/python_classes_objects.htm
 Python
 Variables:
 Basic data structures :
 Lists
 Dictionaries
 Tuples
 Basic operators:
 Addition/subtraction
 Division/Mutliplication
 Functions??
3/28/2013 1Let’s Code: Session 3
3/28/2013 2Let’s Code: Session 3
 Problem:
 Build an employee database
3/28/2013 3Let’s Code: Session 3
 Problem:
 Build an employee database
 What attributes do we want to keep?
 Employee Name: e.g. Sylvester Stallone
 Employee Address: e.g. (Beverly Hills, California, USA)
 Employee Id: e.g. 127001
 Employee Salary: e.g. $1000000
 What operations do we want?
 What other things can we do?
3/28/2013 4Let’s Code: Session 3
 Problem:
 Build an employee database
 What attributes do we want to keep?
 What operations do we want?
 Get Employee Name
 Get Employee id
 Change Salary
 Give 100$ bonus if address is in Beverly Hills
 Add a new information about the employee
 Add info about speciality e.g. “Mind Blowing Action Movies”
 What else can we do?
3/28/2013 5Let’s Code: Session 3
 Create an Employee:
 Which data structure to use ??
 Lets use dict
 Attributes:
3/28/2013 6Let’s Code: Session 3
Attribute Type Example
name string “Sylvester Stallone”
address tuple (“Beverly Hills”,”CA”,”USA”)
id int 127001
salary int 1000000
 Create an Employee:
 Functions:
 Now let us extend this to a database >
 Non-object oriented way
 Object Oriented way
3/28/2013 7Let’s Code: Session 3
Actions Example Logic
get_employee_name “Sylvester Stallone”
get_employee_id 127001
change_salary if(address[0] == “Beverly Hills”): salary += 100
Add_new_info Add attribute: Speciality
 Basic philosophy
 A “container” to hold attributes and operations realted
to those attributes in one single place!!
 Anybody having C background?? – lets start of by
thinking of struct: container to hold data
 How about if we have some funcitons?
 What you ask about the syntax?? ok so be it
3/28/2013 8Let’s Code: Session 3
3/28/2013 9Let’s Code: Session 3
 Example of a class:
 Special notes : self
3/28/2013 10Let’s Code: Session 3
 Example of a class:
 Special notes : self
 Looking a bit deepr: where are these created
 Some other concepts
 Adding attributes
 Deleting instances
 Control the delete operation
3/28/2013 11Let’s Code: Session 3
 Problem:
 Build an employee database
 What attributes do we want to keep?
 What operations do we want?
 What else can we do?
 Extend definitons of Employee
 Multiple Inheritance
3/28/2013 12Let’s Code: Session 3
 Creating a “super Employee”
 Use attributes the same as Employee but add a new
attribute: position
 Way out : Inheritance
3/28/2013 13Let’s Code: Session 3
 Change the bonus function
 Give 100$ more if CEO
 Way out function overloading
3/28/2013 14Let’s Code: Session 3
 Multiple Inheritance
 Another “base class”
 Creating the super Duper employee
3/28/2013 15Let’s Code: Session 3
 Operator overloading
 Iterators
 Generators
3/28/2013 16Let’s Code: Session 3
A Big thanks to the sponsor for this session:
 And best of all!! Akamai is currently recruiting for
summer interns. All positions are listed at
jobs.akamai.com or you can send resumes directly to
gkoenig@akamai.com
3/28/2013 17Let’s Code: Session 3
 Sample Codes:
https://c9.io/pchakraborty/lets-code
 Other refereces:
http://docs.python.org/2/tutorial/classes.html
3/28/2013 18Let’s Code: Session 3

More Related Content

Similar to Lets code classes_python

Mdst 3559-03-03-sql-php-2
Mdst 3559-03-03-sql-php-2Mdst 3559-03-03-sql-php-2
Mdst 3559-03-03-sql-php-2
Rafael Alvarado
 
Cis407 a ilab 6 web application development devry university
Cis407 a ilab 6 web application development devry universityCis407 a ilab 6 web application development devry university
Cis407 a ilab 6 web application development devry university
lhkslkdh89009
 
BigDataCloud meetup - July 8th - Cost effective big-data processing using Ama...
BigDataCloud meetup - July 8th - Cost effective big-data processing using Ama...BigDataCloud meetup - July 8th - Cost effective big-data processing using Ama...
BigDataCloud meetup - July 8th - Cost effective big-data processing using Ama...
BigDataCloud
 
Questions On The Code And Core Module
Questions On The Code And Core ModuleQuestions On The Code And Core Module
Questions On The Code And Core Module
Katie Gulley
 
Sql server 2012 tutorials writing transact-sql statements
Sql server 2012 tutorials   writing transact-sql statementsSql server 2012 tutorials   writing transact-sql statements
Sql server 2012 tutorials writing transact-sql statements
Steve Xu
 

Similar to Lets code classes_python (20)

Mdst 3559-03-03-sql-php-2
Mdst 3559-03-03-sql-php-2Mdst 3559-03-03-sql-php-2
Mdst 3559-03-03-sql-php-2
 
Top 5 things to know about sql azure for developers
Top 5 things to know about sql azure for developersTop 5 things to know about sql azure for developers
Top 5 things to know about sql azure for developers
 
Machine learning
Machine learning Machine learning
Machine learning
 
JavaOne 2007 - TS4721
JavaOne 2007 - TS4721 JavaOne 2007 - TS4721
JavaOne 2007 - TS4721
 
Microsoft azure data fundamentals (dp 900) practice tests 2022
Microsoft azure data fundamentals (dp 900) practice tests 2022Microsoft azure data fundamentals (dp 900) practice tests 2022
Microsoft azure data fundamentals (dp 900) practice tests 2022
 
Cis407 a ilab 6 web application development devry university
Cis407 a ilab 6 web application development devry universityCis407 a ilab 6 web application development devry university
Cis407 a ilab 6 web application development devry university
 
Python SQLite3...
Python                                                                SQLite3...Python                                                                SQLite3...
Python SQLite3...
 
Tech bug webinar Blackboard Learn OpenDB
Tech bug webinar Blackboard Learn OpenDBTech bug webinar Blackboard Learn OpenDB
Tech bug webinar Blackboard Learn OpenDB
 
Sql Lab 4 Essay
Sql Lab 4 EssaySql Lab 4 Essay
Sql Lab 4 Essay
 
Sql Server 2000
Sql Server 2000Sql Server 2000
Sql Server 2000
 
Entity Query API
Entity Query APIEntity Query API
Entity Query API
 
BigDataCloud meetup - July 8th - Cost effective big-data processing using Ama...
BigDataCloud meetup - July 8th - Cost effective big-data processing using Ama...BigDataCloud meetup - July 8th - Cost effective big-data processing using Ama...
BigDataCloud meetup - July 8th - Cost effective big-data processing using Ama...
 
Aen007 Kenigsberg 091807
Aen007 Kenigsberg 091807Aen007 Kenigsberg 091807
Aen007 Kenigsberg 091807
 
bmarshall teaching Calculation Manager on prem
bmarshall teaching Calculation Manager on prembmarshall teaching Calculation Manager on prem
bmarshall teaching Calculation Manager on prem
 
PATTERNS07 - Data Representation in C#
PATTERNS07 - Data Representation in C#PATTERNS07 - Data Representation in C#
PATTERNS07 - Data Representation in C#
 
DBMS LAB FILE1 task 1 , task 2, task3 and many more.pdf
DBMS LAB FILE1 task 1 , task 2, task3 and many more.pdfDBMS LAB FILE1 task 1 , task 2, task3 and many more.pdf
DBMS LAB FILE1 task 1 , task 2, task3 and many more.pdf
 
Questions On The Code And Core Module
Questions On The Code And Core ModuleQuestions On The Code And Core Module
Questions On The Code And Core Module
 
Sql server 2012 tutorials writing transact-sql statements
Sql server 2012 tutorials   writing transact-sql statementsSql server 2012 tutorials   writing transact-sql statements
Sql server 2012 tutorials writing transact-sql statements
 
Pattern matching presentation
Pattern matching presentationPattern matching presentation
Pattern matching presentation
 
dude wheres my domain admins v1.pptx
dude wheres my domain admins v1.pptxdude wheres my domain admins v1.pptx
dude wheres my domain admins v1.pptx
 

More from Iccha Sethi (8)

Resilient Event Driven Systems With Kafka
Resilient Event Driven Systems With KafkaResilient Event Driven Systems With Kafka
Resilient Event Driven Systems With Kafka
 
Redis High availability and fault tolerance in a multitenant environment
Redis High availability and fault tolerance in a multitenant environmentRedis High availability and fault tolerance in a multitenant environment
Redis High availability and fault tolerance in a multitenant environment
 
So youwanttobeopenstackcontributor
So youwanttobeopenstackcontributorSo youwanttobeopenstackcontributor
So youwanttobeopenstackcontributor
 
OpenStack Workshop - WECode Harvard Conference
OpenStack Workshop - WECode Harvard ConferenceOpenStack Workshop - WECode Harvard Conference
OpenStack Workshop - WECode Harvard Conference
 
Grace Hopper Conference Opensource Day - OpenStack workshop
Grace Hopper Conference Opensource Day - OpenStack workshopGrace Hopper Conference Opensource Day - OpenStack workshop
Grace Hopper Conference Opensource Day - OpenStack workshop
 
Python 101 1
Python 101   1Python 101   1
Python 101 1
 
Osrs
OsrsOsrs
Osrs
 
Clinician Decision Support Dashboard
Clinician Decision Support DashboardClinician Decision Support Dashboard
Clinician Decision Support Dashboard
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 

Lets code classes_python

  • 1. Presented by: Prithwish Chakraborty LET’S CODE!!! Sponsored by: AKAMAI Reference: http://www.tutorialspoint.com/python/python_classes_objects.htm
  • 2.  Python  Variables:  Basic data structures :  Lists  Dictionaries  Tuples  Basic operators:  Addition/subtraction  Division/Mutliplication  Functions?? 3/28/2013 1Let’s Code: Session 3
  • 4.  Problem:  Build an employee database 3/28/2013 3Let’s Code: Session 3
  • 5.  Problem:  Build an employee database  What attributes do we want to keep?  Employee Name: e.g. Sylvester Stallone  Employee Address: e.g. (Beverly Hills, California, USA)  Employee Id: e.g. 127001  Employee Salary: e.g. $1000000  What operations do we want?  What other things can we do? 3/28/2013 4Let’s Code: Session 3
  • 6.  Problem:  Build an employee database  What attributes do we want to keep?  What operations do we want?  Get Employee Name  Get Employee id  Change Salary  Give 100$ bonus if address is in Beverly Hills  Add a new information about the employee  Add info about speciality e.g. “Mind Blowing Action Movies”  What else can we do? 3/28/2013 5Let’s Code: Session 3
  • 7.  Create an Employee:  Which data structure to use ??  Lets use dict  Attributes: 3/28/2013 6Let’s Code: Session 3 Attribute Type Example name string “Sylvester Stallone” address tuple (“Beverly Hills”,”CA”,”USA”) id int 127001 salary int 1000000
  • 8.  Create an Employee:  Functions:  Now let us extend this to a database >  Non-object oriented way  Object Oriented way 3/28/2013 7Let’s Code: Session 3 Actions Example Logic get_employee_name “Sylvester Stallone” get_employee_id 127001 change_salary if(address[0] == “Beverly Hills”): salary += 100 Add_new_info Add attribute: Speciality
  • 9.  Basic philosophy  A “container” to hold attributes and operations realted to those attributes in one single place!!  Anybody having C background?? – lets start of by thinking of struct: container to hold data  How about if we have some funcitons?  What you ask about the syntax?? ok so be it 3/28/2013 8Let’s Code: Session 3
  • 10. 3/28/2013 9Let’s Code: Session 3  Example of a class:  Special notes : self
  • 11. 3/28/2013 10Let’s Code: Session 3  Example of a class:  Special notes : self  Looking a bit deepr: where are these created
  • 12.  Some other concepts  Adding attributes  Deleting instances  Control the delete operation 3/28/2013 11Let’s Code: Session 3
  • 13.  Problem:  Build an employee database  What attributes do we want to keep?  What operations do we want?  What else can we do?  Extend definitons of Employee  Multiple Inheritance 3/28/2013 12Let’s Code: Session 3
  • 14.  Creating a “super Employee”  Use attributes the same as Employee but add a new attribute: position  Way out : Inheritance 3/28/2013 13Let’s Code: Session 3
  • 15.  Change the bonus function  Give 100$ more if CEO  Way out function overloading 3/28/2013 14Let’s Code: Session 3
  • 16.  Multiple Inheritance  Another “base class”  Creating the super Duper employee 3/28/2013 15Let’s Code: Session 3
  • 17.  Operator overloading  Iterators  Generators 3/28/2013 16Let’s Code: Session 3
  • 18. A Big thanks to the sponsor for this session:  And best of all!! Akamai is currently recruiting for summer interns. All positions are listed at jobs.akamai.com or you can send resumes directly to gkoenig@akamai.com 3/28/2013 17Let’s Code: Session 3
  • 19.  Sample Codes: https://c9.io/pchakraborty/lets-code  Other refereces: http://docs.python.org/2/tutorial/classes.html 3/28/2013 18Let’s Code: Session 3

Editor's Notes

  1. Jump to code: Work through it.
  2. Jump to code: Create Standalone functions
  3. Second bullet: cue – type in a few attribute namesThird bullet: cue – type in a few function names
  4. Cue: go through the concepts:start with class variablefunctionexample of an initializationnotes about init
  5. Cue: go through the concepts:start with class variablefunctionexample of an initializationnotes about init
  6. Cue: go to the demo