From f8076afb165c4cc488e37894f06f961b026241e6 Mon Sep 17 00:00:00 2001 From: ASPP Student Date: Thu, 25 Sep 2025 10:38:49 +0300 Subject: [PATCH] Add solution --- .../exercises/particle_update_position.ipynb | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/class_materials/exercises/particle_update_position.ipynb b/class_materials/exercises/particle_update_position.ipynb index b3d829a..2a880a8 100644 --- a/class_materials/exercises/particle_update_position.ipynb +++ b/class_materials/exercises/particle_update_position.ipynb @@ -35,7 +35,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 1, "metadata": { "pycharm": { "name": "#%%\n" @@ -59,10 +59,33 @@ " 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": 2, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "8.28" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "particle.update_position(position = 8.2, dt = 0.1)" + ] + }, { "cell_type": "code", "execution_count": 3, @@ -118,7 +141,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.11" + "version": "3.13.6" }, "toc": { "nav_menu": { @@ -142,5 +165,5 @@ } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 4 }