wolterpynaffit / 071023-ph3-python-oop

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Object Oriented Programming in Python

Learning Goals

  • Importing modules

  • Object Oriented Programming

  • Benefits and Principles of OOP Design

  • Classes

  • Instances

  • Initializing with attributes using init

  • Instance methods

  • Showing instances using repr

  • Self

  • Stretch Topics: Object properties

  • Stretch Topics: Class attributes and methods

Exercise

  1. Humans initialize with a first_name and last_name.

  2. Humans initialize with an _age of 0. This will be a property (age) later.

  3. Give humans a __repr__ that adequately shows their characteristics. You decide what this looks like.

  4. Give humans a method say_full_name which returns their concatenated first_name and last_name.

  5. Give humans a method happy_birthday which increments that human's age by 1.

  6. Give humans a property age. When someone attempts to set a human's age directly it instead doesn't change and returns the string "Quit lying about your age!".

About


Languages

Language:Python 100.0%