|
50 | 50 | "outputs": [], |
51 | 51 | "source": [ |
52 | 52 | "# 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())" |
55 | 55 | ] |
56 | 56 | }, |
57 | 57 | { |
|
101 | 101 | "metadata": {}, |
102 | 102 | "source": [ |
103 | 103 | "## 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." |
105 | 105 | ] |
106 | 106 | }, |
107 | 107 | { |
|
237 | 237 | "# Display formatted results at correct level of significance\n", |
238 | 238 | "# Adjust each format string as appropriate\n", |
239 | 239 | "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}\")" |
243 | 243 | ] |
244 | 244 | }, |
245 | 245 | { |
|
340 | 340 | "outputs": [], |
341 | 341 | "source": [ |
342 | 342 | "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}\")" |
345 | 345 | ] |
346 | 346 | }, |
347 | 347 | { |
|
0 commit comments