Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
taupalosaurus committed Oct 17, 2018
1 parent 2bb613e commit 38d2df6
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 76 deletions.
111 changes: 36 additions & 75 deletions lecture1/lecture.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"from lecture import *"
Expand Down Expand Up @@ -110,7 +108,6 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true,
"slideshow": {
"slide_type": "fragment"
}
Expand Down Expand Up @@ -183,7 +180,6 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true,
"slideshow": {
"slide_type": "subslide"
}
Expand Down Expand Up @@ -233,7 +229,6 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true,
"slideshow": {
"slide_type": "fragment"
}
Expand Down Expand Up @@ -276,7 +271,6 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true,
"slideshow": {
"slide_type": "fragment"
}
Expand Down Expand Up @@ -335,9 +329,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"grade = ok.grade('question-1_2')"
Expand All @@ -361,7 +353,6 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true,
"slideshow": {
"slide_type": "fragment"
}
Expand Down Expand Up @@ -397,7 +388,6 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true,
"slideshow": {
"slide_type": "fragment"
}
Expand Down Expand Up @@ -446,13 +436,13 @@
"# import pi from Python's math library\n",
"from math import pi\n",
"\n",
"density = 1.2 # units of kg m^{−3}$\n",
"ball_radius = 0.11 # m\n",
"A = pi*ball_radius # Cross sectional area of a sphere\n",
"mass = 0.43 # kg\n",
"C_D = 0.2 # Drag coefficient\n",
"density = 1.2 # units of kg m^{−3}$\n",
"ball_radius = 0.11 # m\n",
"A = pi*ball_radius**2 # Cross sectional area of a sphere\n",
"mass = 0.43 # kg\n",
"C_D = 0.2 # Drag coefficient\n",
"\n",
"V = 50.8 # m/s (fastest recorded speed of football)\n",
"V = 50.8 # m/s (fastest recorded speed of football)\n",
"\n",
"# Uncomment and complete the following code.\n",
"# F_d = \n",
Expand All @@ -465,9 +455,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"grade = ok.grade('question-1_3')"
Expand Down Expand Up @@ -530,9 +518,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"grade = ok.grade('question-1_4')"
Expand All @@ -558,7 +544,6 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true,
"slideshow": {
"slide_type": "fragment"
}
Expand All @@ -585,7 +570,6 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true,
"slideshow": {
"slide_type": "fragment"
}
Expand All @@ -612,7 +596,6 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true,
"slideshow": {
"slide_type": "fragment"
}
Expand All @@ -639,7 +622,6 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true,
"slideshow": {
"slide_type": "fragment"
}
Expand Down Expand Up @@ -687,9 +669,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"grade = ok.grade('question-1_5')"
Expand Down Expand Up @@ -734,9 +714,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"grade = ok.grade('question-1_6')"
Expand Down Expand Up @@ -808,9 +786,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"print(\"Ball height: %g meters.\"%ball_height(5, 0.6))"
Expand All @@ -828,9 +804,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"# Function to compute height of ball.\n",
Expand Down Expand Up @@ -899,9 +873,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"def somefunc(arg1, arg2, kwarg1=True, kwarg2=0):\n",
Expand All @@ -913,9 +885,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"somefunc(\"Hello\", [1,2], kwarg1=\"Hi\")"
Expand All @@ -924,9 +894,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"somefunc(\"Hello\", [1,2], kwarg2=\"Hi\")"
Expand All @@ -935,9 +903,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"somefunc(\"Hello\", [1,2], kwarg2=\"Hi\", kwarg1=6)"
Expand All @@ -953,9 +919,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"somefunc(kwarg2=\"Hello\", arg1=\"Hi\", kwarg1=6, arg2=[2])"
Expand Down Expand Up @@ -988,9 +952,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"ok.grade('question-1_7')"
Expand All @@ -1000,7 +962,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## <span style=\"color:blue\">Exercice 1.8:</span> How to cook the perfect egg\n",
"## <span style=\"color:blue\">Exercice 1.8 (\\*\\*\\*):</span> How to cook the perfect egg\n",
"\n",
"You just started University and moved away from home. You're trying to impress your new flatmates by cooking brunch. Write a python script to help you cook the perfect eggs! \n",
"\n",
Expand All @@ -1019,9 +981,11 @@
"* $Tw$ temperature of the boiling water (in C degrees) \n",
"* $T0$ is the initial temeprature of the egg (in C degrees), before being put in the water.\n",
"\n",
"Write a function that returns the time `t` needed for the egg to cook, knowing that `Tw` = 100$^\\circ$ C, `M` = 50 g, `rho` = 1.038 gcm$^{−3}$, `c` = 3.7 Jg$^{−1}$K$^{−1}$, and `K` = 5.4 · 10$^{−3}$Wcm$^{−1}$K$^{−1}$. Find `t` for an egg taken from the fridge (`T0` = 4 C) and for one at room temperature (`T0` = 20 C). \n",
"Write a function that returns the time `t` needed for the egg to cook for a given `T0`, knowing that `Tw` = 100$^\\circ$ C, `M` = 50 g, `rho` = 1.038 gcm$^{−3}$, `c` = 3.7 Jg$^{−1}$K$^{−1}$, and `K` = 5.4 · 10$^{−3}$Wcm$^{−1}$K$^{−1}$. `Ty` = 70 $^\\circ$ C. for a perfect soft boiled egg. All these quantities should be passed as keyword arguments, with the specified default values.\n",
"\n",
"Find `t` for an egg taken from the fridge (`T0` = 4 C) and for one at room temperature (`T0` = 20 C). \n",
"\n",
"Hint: You do not need to do any unit conversion. `Ty` = 70 $^\\circ$ C. for a perfect soft boiled egg. "
"Hint: You do not need to do any unit conversion. "
]
},
{
Expand All @@ -1044,9 +1008,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"ok.grade('question-1_8')"
Expand All @@ -1056,7 +1018,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## <span style=\"color:blue\">Exercice 1.9:</span> Kepler's third law\n",
"## <span style=\"color:blue\">Exercice 1.9 (\\*\\*\\*):</span> Kepler's third law\n",
"\n",
"You were selected to be the next astronaut to go to Mars. Congratulations! \n",
"\n",
Expand Down Expand Up @@ -1092,22 +1054,23 @@
"source": [
"# Uncomment and complete this code - keep the names the same for testing purposes. \n",
"\n",
"#from math import pi, sqrt\n",
"# from ... import ...\n",
"\n",
"#def period(a, G=6.67*10**-11, m1=6*10**24 , m2=2*10**30):\n",
"# def period(a, G=6.67*10**-11, m1=6*10**24 , m2=2*10**30):\n",
"# ...\n",
"# \n",
"# return P_mars, P_earth, birthdays\n",
"# return P_mars, P_earth\n",
"\n",
"# P_mars, P_earth = period(1.5*10**11)\n",
"# birthdays = ...\n",
"\n",
"#print(period(1.5*10**11))"
"# print(\"Periods: \", period(1.5*10**11), \", birthdays: \", birthdays)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"ok.grade('question-1_9')"
Expand All @@ -1116,9 +1079,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
" ok.score()"
Expand Down
8 changes: 8 additions & 0 deletions lecture1/tests/question-1_8.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@
""",
'hidden': False,
'locked': False
},
{
'code': r"""
>>> np.allclose( perfect_egg(20), 259.342856)
True
""",
'hidden': False,
'locked': False
}
],
'scored': True,
Expand Down
10 changes: 9 additions & 1 deletion lecture1/tests/question-1_9.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,15 @@
'cases': [
{
'code': r"""
>>> np.allclose( period(1.5*10**11), [58059817.3950661, 31603718.929927427, 18.3711978719333])
>>> np.allclose( period(1.5*10**11), [58059817.3950661, 31603718.929927427])
True
""",
'hidden': False,
'locked': False
},
{
'code': r"""
>>> np.isclose( birthdays, 18.37119787)
True
""",
'hidden': False,
Expand Down

0 comments on commit 38d2df6

Please sign in to comment.