You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.1 KiB

2 years ago
  1. {
  2. "cells": [
  3. {
  4. "cell_type": "code",
  5. "execution_count": null,
  6. "metadata": {},
  7. "outputs": [],
  8. "source": [
  9. "from math import sqrt\n",
  10. "i = 1\n",
  11. "s = 0\n",
  12. "item = 1\n",
  13. "while item > 0.000001:\n",
  14. " s = s + item\n",
  15. " i = i + 1\n",
  16. " item = 1 / (i * i)\n",
  17. "pi = sqrt(6 * s)\n",
  18. "print(\"pi 的值是{}\".format(pi))"
  19. ]
  20. }
  21. ],
  22. "metadata": {
  23. "kernelspec": {
  24. "display_name": "Python 3",
  25. "language": "python",
  26. "name": "python3"
  27. },
  28. "language_info": {
  29. "codemirror_mode": {
  30. "name": "ipython",
  31. "version": 3
  32. },
  33. "file_extension": ".py",
  34. "mimetype": "text/x-python",
  35. "name": "python",
  36. "nbconvert_exporter": "python",
  37. "pygments_lexer": "ipython3",
  38. "version": "3.7.3"
  39. },
  40. "toc": {
  41. "base_numbering": 1,
  42. "nav_menu": {},
  43. "number_sections": true,
  44. "sideBar": true,
  45. "skip_h1_title": false,
  46. "title_cell": "Table of Contents",
  47. "title_sidebar": "Contents",
  48. "toc_cell": false,
  49. "toc_position": {},
  50. "toc_section_display": true,
  51. "toc_window_display": false
  52. }
  53. },
  54. "nbformat": 4,
  55. "nbformat_minor": 2
  56. }