diff --git a/lab-oop_in_python.ipynb b/lab-oop_in_python.ipynb index 3142c5e..3f2c247 100644 --- a/lab-oop_in_python.ipynb +++ b/lab-oop_in_python.ipynb @@ -30,20 +30,34 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "240 18\n", + "300 10\n" + ] + } + ], "source": [ "# Your code here\n", "class Vehicle:\n", " # Hint: Define __init__ method with parameters for max_speed and mileage\n", " pass\n", + " def __init__(self, max_speed, mileage):\n", + " self.max_speed = max_speed\n", + " self.mileage = mileage\n", "\n", "# Example instantiation\n", - "modelX = Vehicle() # Create an instance of Vehicle\n", + "modelX = Vehicle(240,18) # Create an instance of Vehicle\n", + "bmwx3 = Vehicle(300,10)\n", "\n", "# Print attributes\n", - "print(modelX.max_speed, modelX.mileage) # Expected output: (value of max_speed, value of mileage)" + "print(modelX.max_speed, modelX.mileage) # Expected output: (value of max_speed, value of mileage)\n", + "print(bmwx3.max_speed, bmwx3.mileage)" ] }, { @@ -56,7 +70,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 13, "metadata": {}, "outputs": [ { @@ -74,6 +88,7 @@ "\n", "# Example instantiation\n", "my_vehicle = Vehicle()\n", + "\n", "print(type(my_vehicle)) # Expected output: " ] }, @@ -87,7 +102,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 14, "metadata": {}, "outputs": [ { @@ -105,6 +120,7 @@ "\n", "# Example instantiation\n", "school_bus = Bus()\n", + "\n", "print(type(school_bus)) # Expected output: " ] }, @@ -118,7 +134,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 15, "metadata": {}, "outputs": [ { @@ -140,6 +156,8 @@ " pass\n", "\n", "school_bus = Bus()\n", + "\n", + "\n", "print(school_bus.fare()) # Expected output: \"Base fare with extra charge\"" ] }, @@ -153,7 +171,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 22, "metadata": {}, "outputs": [ { @@ -168,14 +186,17 @@ "# Your code here\n", "class Vehicle:\n", " color = \"White\" # Hint: Define color as a class attribute\n", + " \n", "\n", " def __init__(self, name, max_speed, mileage):\n", " self.name = name\n", " self.max_speed = max_speed\n", " self.mileage = mileage\n", "\n", + "\n", + "\n", "school_bus = Vehicle(\"School Volvo\", 180, 12)\n", - "print(school_bus.color) # Expected output: \"White\"" + "print(school_bus.color) # Expected output: \"White\"\n" ] }, { @@ -188,7 +209,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 23, "metadata": {}, "outputs": [ { @@ -228,7 +249,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 24, "metadata": {}, "outputs": [ { @@ -255,7 +276,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 25, "metadata": {}, "outputs": [ { @@ -287,7 +308,7 @@ ], "metadata": { "kernelspec": { - "display_name": ".venv", + "display_name": "Python 3", "language": "python", "name": "python3" }, @@ -301,7 +322,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.0" + "version": "3.9.6" } }, "nbformat": 4,