diff --git a/lab-oop_in_python.ipynb b/lab-oop_in_python.ipynb index 3142c5e..b7d19bb 100644 --- a/lab-oop_in_python.ipynb +++ b/lab-oop_in_python.ipynb @@ -30,21 +30,36 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], + "metadata": { + "ExecuteTime": { + "end_time": "2025-10-08T13:04:01.130371Z", + "start_time": "2025-10-08T13:04:01.122328Z" + } + }, "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", "\n", "# Example instantiation\n", - "modelX = Vehicle() # Create an instance of Vehicle\n", + "modelX = Vehicle(10,100) # Create an instance of Vehicle\n", "\n", "# Print attributes\n", "print(modelX.max_speed, modelX.mileage) # Expected output: (value of max_speed, value of mileage)" - ] + ], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "10 100\n" + ] + } + ], + "execution_count": 4 }, { "cell_type": "markdown", @@ -56,8 +71,21 @@ }, { "cell_type": "code", - "execution_count": 2, - "metadata": {}, + "metadata": { + "ExecuteTime": { + "end_time": "2025-10-08T13:05:08.338450Z", + "start_time": "2025-10-08T13:05:08.328792Z" + } + }, + "source": [ + "# Your code here\n", + "class Vehicle:\n", + " pass\n", + "\n", + "# Example instantiation\n", + "my_vehicle = Vehicle()\n", + "print(type(my_vehicle)) # Expected output: " + ], "outputs": [ { "name": "stdout", @@ -67,15 +95,7 @@ ] } ], - "source": [ - "# Your code here\n", - "class Vehicle:\n", - " pass\n", - "\n", - "# Example instantiation\n", - "my_vehicle = Vehicle()\n", - "print(type(my_vehicle)) # Expected output: " - ] + "execution_count": 7 }, { "cell_type": "markdown", @@ -87,17 +107,12 @@ }, { "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n" - ] + "metadata": { + "ExecuteTime": { + "end_time": "2025-10-08T13:05:26.509859Z", + "start_time": "2025-10-08T13:05:26.500373Z" } - ], + }, "source": [ "# Your code here\n", "class Bus(Vehicle):\n", @@ -106,7 +121,17 @@ "# Example instantiation\n", "school_bus = Bus()\n", "print(type(school_bus)) # Expected output: " - ] + ], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n" + ] + } + ], + "execution_count": 8 }, { "cell_type": "markdown", @@ -118,17 +143,12 @@ }, { "cell_type": "code", - "execution_count": 4, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Base fare\n" - ] + "metadata": { + "ExecuteTime": { + "end_time": "2025-10-08T13:07:04.350537Z", + "start_time": "2025-10-08T13:07:04.337318Z" } - ], + }, "source": [ "# Your code here\n", "class Vehicle:\n", @@ -136,12 +156,22 @@ " return \"Base fare\"\n", "\n", "class Bus(Vehicle):\n", - " # Hint: Override fare method to include extra charges\n", - " pass\n", + " def fare(self):\n", + " return \"Base fare with extra charge\"\n", "\n", "school_bus = Bus()\n", "print(school_bus.fare()) # Expected output: \"Base fare with extra charge\"" - ] + ], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Base fare with extra charge\n" + ] + } + ], + "execution_count": 10 }, { "cell_type": "markdown", @@ -153,17 +183,12 @@ }, { "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "White\n" - ] + "metadata": { + "ExecuteTime": { + "end_time": "2025-10-08T13:07:14.881469Z", + "start_time": "2025-10-08T13:07:14.867772Z" } - ], + }, "source": [ "# Your code here\n", "class Vehicle:\n", @@ -176,7 +201,17 @@ "\n", "school_bus = Vehicle(\"School Volvo\", 180, 12)\n", "print(school_bus.color) # Expected output: \"White\"" - ] + ], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "White\n" + ] + } + ], + "execution_count": 11 }, { "cell_type": "markdown", @@ -188,17 +223,12 @@ }, { "cell_type": "code", - "execution_count": 6, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Total Bus fare is: 5000\n" - ] + "metadata": { + "ExecuteTime": { + "end_time": "2025-10-08T13:07:29.615517Z", + "start_time": "2025-10-08T13:07:29.600831Z" } - ], + }, "source": [ "# Your code here\n", "class Vehicle:\n", @@ -216,7 +246,17 @@ "\n", "school_bus = Bus(\"School Volvo\", 12, 50)\n", "print(\"Total Bus fare is:\", school_bus.fare()) # Expected output: Total Bus fare is: (calculated amount)" - ] + ], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Total Bus fare is: 5000\n" + ] + } + ], + "execution_count": 12 }, { "cell_type": "markdown", @@ -228,8 +268,17 @@ }, { "cell_type": "code", - "execution_count": 7, - "metadata": {}, + "metadata": { + "ExecuteTime": { + "end_time": "2025-10-08T13:08:03.211646Z", + "start_time": "2025-10-08T13:08:03.203836Z" + } + }, + "source": [ + "# Your code here\n", + "school_bus = Bus(\"School Volvo\", 12, 50)\n", + "print(type(school_bus)) # Expected output: " + ], "outputs": [ { "name": "stdout", @@ -239,11 +288,7 @@ ] } ], - "source": [ - "# Your code here\n", - "school_bus = Bus(\"School Volvo\", 12, 50)\n", - "print(type(school_bus)) # Expected output: " - ] + "execution_count": 13 }, { "cell_type": "markdown", @@ -255,8 +300,16 @@ }, { "cell_type": "code", - "execution_count": 8, - "metadata": {}, + "metadata": { + "ExecuteTime": { + "end_time": "2025-10-08T13:08:16.753553Z", + "start_time": "2025-10-08T13:08:16.743317Z" + } + }, + "source": [ + "# Your code here\n", + "print(isinstance(school_bus, Vehicle)) # Expected output: True or False based on inheritance" + ], "outputs": [ { "name": "stdout", @@ -266,10 +319,7 @@ ] } ], - "source": [ - "# Your code here\n", - "print(isinstance(school_bus, Vehicle)) # Expected output: True or False based on inheritance" - ] + "execution_count": 14 }, { "cell_type": "markdown",