Skip to content

Commit f0d32c8

Browse files
committed
Update NB A.3 with f-strings
1 parent 0aadf1e commit f0d32c8

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

notebooks/A.3-Template-Fit.ipynb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@
5050
"outputs": [],
5151
"source": [
5252
"# Display file contents\n",
53-
"file = open('data/Example-Data.csv', 'r')\n",
54-
"print(file.read())"
53+
"with open('data/Example-Data.csv', 'r') as file:\n",
54+
" print(file.read())"
5555
]
5656
},
5757
{
@@ -101,7 +101,7 @@
101101
"metadata": {},
102102
"source": [
103103
"## Step 3: Plot the data\n",
104-
"Change the variable names, title, axis labels, etc, as appropriate."
104+
"Change the variable names, title, axis labels, etc., as appropriate."
105105
]
106106
},
107107
{
@@ -237,9 +237,9 @@
237237
"# Display formatted results at correct level of significance\n",
238238
"# Adjust each format string as appropriate\n",
239239
"print(\"Correctly formatted precision:\")\n",
240-
"print(\"Model slope (mV/Hz): {0:.2f} ± {1:.2f}\".format(mOpt, mAlpha))\n",
241-
"print(\"Model intercept (mV): {0:.0f} ± {1:.0f}\".format(bOpt, bAlpha))\n",
242-
"print(\"Correlation coefficient: {0:.1f}\".format(rho_mb))"
240+
"print(f\"Model slope (mV/Hz): {mOpt:.2f} ± {mAlpha:.2f}\")\n",
241+
"print(f\"Model intercept (mV): {bOpt:.0f} ± {bAlpha:.0f}\")\n",
242+
"print(\"Correlation coefficient: {rho_mb:.1f}\")"
243243
]
244244
},
245245
{
@@ -340,8 +340,8 @@
340340
"outputs": [],
341341
"source": [
342342
"cdf = chi2.cdf(chisq,dof)\n",
343-
"print(\"Cumulative probability = {0:.3f}\".format(cdf))\n",
344-
"print(\"Significance: {0:.3f}\".format(1-cdf))"
343+
"print(f\"Cumulative probability = {cdf:.3f}\")\n",
344+
"print(f\"Significance: {1-cdf:.3f}\")"
345345
]
346346
},
347347
{

0 commit comments

Comments
 (0)