solution
This commit is contained in:
parent
3d3d3913ef
commit
cbefc77266
1 changed files with 28 additions and 10 deletions
|
@ -17,7 +17,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"execution_count": 5,
|
||||
"metadata": {
|
||||
"ExecuteTime": {
|
||||
"end_time": "2018-07-27T15:05:51.531289Z",
|
||||
|
@ -35,7 +35,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"execution_count": 3,
|
||||
"metadata": {
|
||||
"pycharm": {
|
||||
"name": "#%%\n"
|
||||
|
@ -52,20 +52,25 @@
|
|||
],
|
||||
"source": [
|
||||
"class Particle:\n",
|
||||
" def __init__(self, mass, velocity):\n",
|
||||
" def __init__(self, mass, velocity, position):\n",
|
||||
" self.mass = mass\n",
|
||||
" self.velocity = velocity\n",
|
||||
" self.position = position\n",
|
||||
"\n",
|
||||
" def momentum(self):\n",
|
||||
" return self.mass * self.velocity\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())"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"execution_count": 6,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
|
@ -84,10 +89,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.position"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
|
@ -104,7 +122,7 @@
|
|||
"metadata": {
|
||||
"hide_input": false,
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3 (ipykernel)",
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
|
@ -118,7 +136,7 @@
|
|||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.10.11"
|
||||
"version": "3.13.7"
|
||||
},
|
||||
"toc": {
|
||||
"nav_menu": {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue