Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mooc-rr
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
036332d1e8a8fad18eace193f300e27a
mooc-rr
Commits
aed94fca
Commit
aed94fca
authored
Jun 20, 2025
by
036332d1e8a8fad18eace193f300e27a
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Module 2 Exercises
parent
e391755a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
101 additions
and
3 deletions
+101
-3
toy_notebook_fr.ipynb
module2/exo1/toy_notebook_fr.ipynb
+101
-3
No files found.
module2/exo1/toy_notebook_fr.ipynb
View file @
aed94fca
{
"cells": [],
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Module 2"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"from random import random \n",
"N=10000\n",
"val=sum(\n",
"1 for _ in range(N)\n",
" if random()**2 + random()**2 <= 1\n",
")\n",
"\n",
"pi_estimate = 4 * val / N"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"3.1672"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"pi_estimate"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"a x b = 196\n"
]
}
],
"source": [
"a=14\n",
"b=14\n",
"prod=a*b\n",
"print(\"a x b =\", prod)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import matplotlib.pyplot as plt\n",
"\n",
"x = [1,2, 3, 4]\n",
"y = [4, 8, 12, 16]\n",
"\n",
"plt.plot(x, y)\n",
"plt.title( \"Plot\")\n",
"plt.xlabel(\"x\")\n",
"plt.ylabel(\"y = 4x \")\n",
"plt.show()\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
...
...
@@ -16,10 +115,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.
3
"
"version": "3.6.
4
"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment