solution #12
1 changed files with 28 additions and 10 deletions
|
@ -17,7 +17,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 1,
|
"execution_count": 5,
|
||||||
"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": 3,
|
||||||
"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": 6,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
|
@ -84,10 +89,23 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": 8,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [
|
||||||
"source": []
|
{
|
||||||
|
"data": {
|
||||||
|
"text/plain": [
|
||||||
|
"8.28"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"execution_count": 8,
|
||||||
|
"metadata": {},
|
||||||
|
"output_type": "execute_result"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"particle.position"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
|
@ -104,7 +122,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 +136,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": {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue