diff --git a/lab-oop_in_python.ipynb b/lab-oop_in_python.ipynb index 3142c5e..8caad8f 100644 --- a/lab-oop_in_python.ipynb +++ b/lab-oop_in_python.ipynb @@ -30,13 +30,26 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 15, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "0 0\n" + ] + } + ], "source": [ "# Your code here\n", "class Vehicle:\n", - " # Hint: Define __init__ method with parameters for max_speed and mileage\n", + " max_speed = 0\n", + " mileage = 0\n", + "\n", + " def __init__(self, max_speed= 0 , mileage=0):\n", + " self.max_speed = max_speed\n", + " self.mileage = mileage\n", " pass\n", "\n", "# Example instantiation\n", @@ -56,7 +69,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 16, "metadata": {}, "outputs": [ { @@ -87,7 +100,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 17, "metadata": {}, "outputs": [ { @@ -118,14 +131,14 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 20, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "Base fare\n" + "Base fare with extra charge\n" ] } ], @@ -137,6 +150,9 @@ "\n", "class Bus(Vehicle):\n", " # Hint: Override fare method to include extra charges\n", + " def fare(self):\n", + " parent_fare = super().fare()\n", + " return parent_fare + \" with extra charge\"\n", " pass\n", "\n", "school_bus = Bus()\n", @@ -153,7 +169,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 21, "metadata": {}, "outputs": [ { @@ -188,14 +204,14 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 23, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "Total Bus fare is: 5000\n" + "Total Bus fare is: 5500.0\n" ] } ], @@ -212,6 +228,10 @@ "\n", "class Bus(Vehicle):\n", " # Hint: Override fare method to include maintenance charge\n", + " def fare(self):\n", + " parent_fare = super().fare()\n", + " total_fare = parent_fare + parent_fare*10/100\n", + " return total_fare\n", " pass\n", "\n", "school_bus = Bus(\"School Volvo\", 12, 50)\n", @@ -228,7 +248,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 24, "metadata": {}, "outputs": [ { @@ -255,7 +275,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 25, "metadata": {}, "outputs": [ { @@ -287,7 +307,7 @@ ], "metadata": { "kernelspec": { - "display_name": ".venv", + "display_name": "base", "language": "python", "name": "python3" }, @@ -301,7 +321,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.0" + "version": "3.13.5" } }, "nbformat": 4,