solution #12

Open
mariiako wants to merge 2 commits from mariiako/2025-plovdiv-scientific-patterns:solution into main

View file

@ -17,7 +17,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": 10,
"metadata": { "metadata": {
"ExecuteTime": { "ExecuteTime": {
"end_time": "2018-07-27T15:05:51.531289Z", "end_time": "2018-07-27T15:05:51.531289Z",
@ -35,7 +35,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": 11,
"metadata": { "metadata": {
"pycharm": { "pycharm": {
"name": "#%%\n" "name": "#%%\n"
@ -52,20 +52,25 @@
], ],
"source": [ "source": [
"class Particle:\n", "class Particle:\n",
" def __init__(self, mass, velocity):\n", " def __init__(self, mass, velocity, position):\n",
" self.mass = mass\n", " self.mass = mass\n",
" self.velocity = velocity\n", " self.velocity = velocity\n",
" self.position = position\n",
"\n", "\n",
" def momentum(self):\n", " def momentum(self):\n",
" return self.mass * self.velocity\n", " return self.mass * self.velocity\n",
"\n", "\n",
"particle = Particle(mass=2.1, velocity=0.8)\n", " def update_position(self, dt):\n",
" self.position = self.position + self.velocity * dt\n",
" return self.position\n",
"\n",
"particle = Particle(mass=2.1, velocity=0.8, position=8.2)\n",
"print(particle.momentum())" "print(particle.momentum())"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 3, "execution_count": 12,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -84,10 +89,24 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 13,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
"source": [] {
"data": {
"text/plain": [
"8.28"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dt=0.1\n",
"particle.update_position(dt)"
]
}, },
{ {
"cell_type": "code", "cell_type": "code",
@ -104,7 +123,7 @@
"metadata": { "metadata": {
"hide_input": false, "hide_input": false,
"kernelspec": { "kernelspec": {
"display_name": "Python 3 (ipykernel)", "display_name": "Python 3",
"language": "python", "language": "python",
"name": "python3" "name": "python3"
}, },
@ -118,7 +137,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.10.11" "version": "3.13.7"
}, },
"toc": { "toc": {
"nav_menu": { "nav_menu": {