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-2Rafael Alvarado
 
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 developersIke Ellis
 
JavaOne 2007 - TS4721
JavaOne 2007 - TS4721 JavaOne 2007 - TS4721
JavaOne 2007 - TS4721 Edgar Silva
 
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 2022SkillCertProExams
 
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 universitylhkslkdh89009
 
Python SQLite3...
Python                                                                SQLite3...Python                                                                SQLite3...
Python SQLite3...VikasTuwar1
 
Tech bug webinar Blackboard Learn OpenDB
Tech bug webinar Blackboard Learn OpenDBTech bug webinar Blackboard Learn OpenDB
Tech bug webinar Blackboard Learn OpenDBScott Hurrey
 
Entity Query API
Entity Query APIEntity Query API
Entity Query APImarcingy
 
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
 
Aen007 Kenigsberg 091807
Aen007 Kenigsberg 091807Aen007 Kenigsberg 091807
Aen007 Kenigsberg 091807Dreamforce07
 
bmarshall teaching Calculation Manager on prem
bmarshall teaching Calculation Manager on prembmarshall teaching Calculation Manager on prem
bmarshall teaching Calculation Manager on premRoma766619
 
PATTERNS07 - Data Representation in C#
PATTERNS07 - Data Representation in C#PATTERNS07 - Data Representation in C#
PATTERNS07 - Data Representation in C#Michael Heron
 
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.pdfAbhishekKumarPandit5
 
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 ModuleKatie 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 statementsSteve Xu
 
Pattern matching presentation
Pattern matching presentationPattern matching presentation
Pattern matching presentationMichael Dimmitt
 
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.pptxJoel Leo
 

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

Resilient Event Driven Systems With Kafka
Resilient Event Driven Systems With KafkaResilient Event Driven Systems With Kafka
Resilient Event Driven Systems With KafkaIccha Sethi
 
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 environmentIccha Sethi
 
So youwanttobeopenstackcontributor
So youwanttobeopenstackcontributorSo youwanttobeopenstackcontributor
So youwanttobeopenstackcontributorIccha Sethi
 
OpenStack Workshop - WECode Harvard Conference
OpenStack Workshop - WECode Harvard ConferenceOpenStack Workshop - WECode Harvard Conference
OpenStack Workshop - WECode Harvard ConferenceIccha Sethi
 
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 workshopIccha Sethi
 
Clinician Decision Support Dashboard
Clinician Decision Support DashboardClinician Decision Support Dashboard
Clinician Decision Support DashboardIccha Sethi
 

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

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
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, Adobeapidays
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
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 TerraformAndrey Devyatkin
 
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 DiscoveryTrustArc
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 

Recently uploaded (20)

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
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
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
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
 
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
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 

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