Add solution
This commit is contained in:
parent
3d3d3913ef
commit
f8076afb16
1 changed files with 26 additions and 3 deletions
|
@ -35,7 +35,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 2,
|
"execution_count": 1,
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"pycharm": {
|
"pycharm": {
|
||||||
"name": "#%%\n"
|
"name": "#%%\n"
|
||||||
|
@ -59,10 +59,33 @@
|
||||||
" def momentum(self):\n",
|
" def momentum(self):\n",
|
||||||
" return self.mass * self.velocity\n",
|
" return self.mass * self.velocity\n",
|
||||||
"\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",
|
"particle = Particle(mass=2.1, velocity=0.8)\n",
|
||||||
"print(particle.momentum())"
|
"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",
|
"cell_type": "code",
|
||||||
"execution_count": 3,
|
"execution_count": 3,
|
||||||
|
@ -118,7 +141,7 @@
|
||||||
"name": "python",
|
"name": "python",
|
||||||
"nbconvert_exporter": "python",
|
"nbconvert_exporter": "python",
|
||||||
"pygments_lexer": "ipython3",
|
"pygments_lexer": "ipython3",
|
||||||
"version": "3.10.11"
|
"version": "3.13.6"
|
||||||
},
|
},
|
||||||
"toc": {
|
"toc": {
|
||||||
"nav_menu": {
|
"nav_menu": {
|
||||||
|
@ -142,5 +165,5 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nbformat": 4,
|
"nbformat": 4,
|
||||||
"nbformat_minor": 2
|
"nbformat_minor": 4
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue