"#Python is an object-oriented language. This allows us to bundle the properties (data) and behaviors (functions) into individual objects, which make them easy to reuse and build upon.\n",
"#data and functions associated with a specific class are called \"attributes\" and \"methods\", respectively."
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<__main__.NiceCar object at 0x112360f98>\n",
"<__main__.NiceCar object at 0x112360fd0>\n",
"BMW\n",
"black\n"
]
}
],
"source": [
"# define a class and skip it for now. The class NiceCar has no attributes or methods.\n",
"class NiceCar:\n",
" pass\n",
"\n",
"#instance of a class:\n",
"#a class is a blueprint for creating instances.\n",
"#my_car1and my_car2 are unique instances of class NiceCar\n",
"my_car1 = NiceCar()\n",
"my_car2 = NiceCar()\n",
"\n",
"print(my_car1) #<__main__.NiceCar object at 0x112360208>\n",
"print(my_car2) #<__main__.NiceCar object at 0x112360160>\n",
"\u001b[0;32m<ipython-input-22-aa4b3cd705ea>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mhermes\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpaint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"orange\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;31mNameError\u001b[0m: name 'hermes' is not defined"