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

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetEnjoy Anytime
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 

Recently uploaded (20)

Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 

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