Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 19 additions & 27 deletions static/array/average.ipynb
Original file line number Diff line number Diff line change
@@ -1,29 +1,21 @@
{
"nbformat": 4,
"nbformat_minor": 2,
"metadata": {},
"cells": [
{
"metadata": {},
"source": [
"score1 = 96\n",
"score2 = 56\n",
"score3 = 42\n",
"score4 = 74\n",
"score5 = 86\n",
"print((score1 + score2 + score3 + score4 + score5) / 5)"
],
"cell_type": "code",
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"70.8\n"
]
}
],
"execution_count": null
}
]
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"score1 = 96\n",
"score2 = 56\n",
"score3 = 42\n",
"score4 = 74\n",
"score5 = 86\n",
"print((score1 + score2 + score3 + score4 + score5) / 5)"
]
}
],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 2
}
52 changes: 22 additions & 30 deletions static/array/average10.ipynb
Original file line number Diff line number Diff line change
@@ -1,32 +1,24 @@
{
"nbformat": 4,
"nbformat_minor": 2,
"metadata": {},
"cells": [
{
"metadata": {},
"source": [
"def average(scores):\n",
" sum = 0\n",
" for i in range(len(scores)):\n",
" sum += scores[i]\n",
" return sum / len(scores)\n",
"\n",
"\n",
"scores = [26, 78, 83, 20, 10, 11, 22, 16, 41, 95]\n",
"print(average(scores))"
],
"cell_type": "code",
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"40.2\n"
]
}
],
"execution_count": null
}
]
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"def average(scores):\n",
" sum = 0\n",
" for i in range(len(scores)):\n",
" sum += scores[i]\n",
" return sum / len(scores)\n",
"\n",
"\n",
"scores = [26, 78, 83, 20, 10, 11, 22, 16, 41, 95]\n",
"print(average(scores))"
]
}
],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 2
}
24 changes: 8 additions & 16 deletions static/array/average2.ipynb
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
{
"nbformat": 4,
"nbformat_minor": 2,
"metadata": {},
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"scores = [96, 56, 42, 74, 86]\n",
"print((scores[0] + scores[1] + scores[2] + scores[3] + scores[4]) / 5)"
],
"cell_type": "code",
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"70.8\n"
]
}
],
"execution_count": null
]
}
]
],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 2
}
24 changes: 8 additions & 16 deletions static/array/average3.ipynb
Original file line number Diff line number Diff line change
@@ -1,28 +1,20 @@
{
"nbformat": 4,
"nbformat_minor": 2,
"metadata": {},
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"scores = [96, 56, 42, 74, 86]\n",
"sum = 0\n",
"for i in range(len(scores)):\n",
" sum += scores[i]\n",
"print(sum / 5)"
],
"cell_type": "code",
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"70.8\n"
]
}
],
"execution_count": null
]
}
]
],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 2
}
42 changes: 17 additions & 25 deletions static/array/average_numpy.ipynb
Original file line number Diff line number Diff line change
@@ -1,27 +1,19 @@
{
"nbformat": 4,
"nbformat_minor": 2,
"metadata": {},
"cells": [
{
"metadata": {},
"source": [
"import numpy\n",
"\n",
"scores = [26, 78, 83, 20, 10, 11, 22, 16, 41, 95]\n",
"print(numpy.mean(scores))"
],
"cell_type": "code",
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"40.2\n"
]
}
],
"execution_count": null
}
]
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import numpy\n",
"\n",
"scores = [26, 78, 83, 20, 10, 11, 22, 16, 41, 95]\n",
"print(numpy.mean(scores))"
]
}
],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 2
}
42 changes: 17 additions & 25 deletions static/array/average_statistics.ipynb
Original file line number Diff line number Diff line change
@@ -1,27 +1,19 @@
{
"nbformat": 4,
"nbformat_minor": 2,
"metadata": {},
"cells": [
{
"metadata": {},
"source": [
"import statistics\n",
"\n",
"scores = [26, 78, 83, 20, 10, 11, 22, 16, 41, 95]\n",
"print(statistics.mean(scores))"
],
"cell_type": "code",
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"40.2\n"
]
}
],
"execution_count": null
}
]
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import statistics\n",
"\n",
"scores = [26, 78, 83, 20, 10, 11, 22, 16, 41, 95]\n",
"print(statistics.mean(scores))"
]
}
],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 2
}
16 changes: 8 additions & 8 deletions static/array/change.ipynb
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"nbformat": 4,
"nbformat_minor": 2,
"metadata": {},
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"scores = [96, 56, 42, 74, 86]\n",
"scores[0] = 37"
],
"cell_type": "code",
"outputs": [],
"execution_count": null
]
}
]
],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 2
}
24 changes: 8 additions & 16 deletions static/array/change2.ipynb
Original file line number Diff line number Diff line change
@@ -1,26 +1,18 @@
{
"nbformat": 4,
"nbformat_minor": 2,
"metadata": {},
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"scores = [96, 56, 42, 74, 86]\n",
"scores[0] = 37\n",
"print(scores)"
],
"cell_type": "code",
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"[37, 56, 42, 74, 86]\n"
]
}
],
"execution_count": null
]
}
]
],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 2
}
24 changes: 8 additions & 16 deletions static/array/change3.ipynb
Original file line number Diff line number Diff line change
@@ -1,28 +1,20 @@
{
"nbformat": 4,
"nbformat_minor": 2,
"metadata": {},
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"scores = [96, 56, 42, 74, 86]\n",
"i = 1\n",
"laterScore = 37\n",
"scores[i - 1] = laterScore\n",
"print(scores)"
],
"cell_type": "code",
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"[37, 56, 42, 74, 86]\n"
]
}
],
"execution_count": null
]
}
]
],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 2
}
25 changes: 8 additions & 17 deletions static/array/range.ipynb
Original file line number Diff line number Diff line change
@@ -1,26 +1,17 @@
{
"nbformat": 4,
"nbformat_minor": 2,
"metadata": {},
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print(range(1, 11))\n",
"print(list(range(1, 11)))"
],
"cell_type": "code",
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"range(1, 11)\n",
"[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n"
]
}
],
"execution_count": null
]
}
]
],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 2
}
Loading