From 1fc40ea003615bcc6e8a6ec7fa3cc4904f249b7b Mon Sep 17 00:00:00 2001 From: ASPP Student Date: Thu, 25 Sep 2025 10:36:53 +0300 Subject: [PATCH] added update_position method --- .../exercises/particle_update_position.ipynb | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/class_materials/exercises/particle_update_position.ipynb b/class_materials/exercises/particle_update_position.ipynb index b3d829a..0093e1d 100644 --- a/class_materials/exercises/particle_update_position.ipynb +++ b/class_materials/exercises/particle_update_position.ipynb @@ -17,7 +17,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 4, "metadata": { "ExecuteTime": { "end_time": "2018-07-27T15:05:51.531289Z", @@ -35,7 +35,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 7, "metadata": { "pycharm": { "name": "#%%\n" @@ -59,13 +59,16 @@ " def momentum(self):\n", " return self.mass * self.velocity\n", "\n", + " def update_position(self, position, dt):\n", + " return position + self.velocity * dt\n", + "\n", "particle = Particle(mass=2.1, velocity=0.8)\n", "print(particle.momentum())" ] }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 5, "metadata": {}, "outputs": [ { @@ -84,10 +87,23 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "data": { + "text/plain": [ + "8.28" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "particle.update_position(position = position, dt = 0.1)" + ] }, { "cell_type": "code", @@ -118,7 +134,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.11" + "version": "3.13.6" }, "toc": { "nav_menu": { @@ -142,5 +158,5 @@ } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 4 } -- 2.39.5