Açıklama Yok

Lab-checkpoint.ipynb 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. {
  2. "cells": [
  3. {
  4. "cell_type": "markdown",
  5. "metadata": {},
  6. "source": [
  7. "# installation\n",
  8. "ตาม links ต่อไปนี้ \n",
  9. "- https://phoenixnap.com/kb/how-to-install-python-3-windows\n",
  10. "- https://docs.python.org/3/library/venv.html\n",
  11. "- https://physics.info/equations/"
  12. ]
  13. },
  14. {
  15. "cell_type": "markdown",
  16. "metadata": {},
  17. "source": [
  18. "# Lab 1.1 \n",
  19. "เขียน program บวกเลข ตั้งแต่ 1 .. n ตัวอย่าง\n",
  20. "n = 10\n",
  21. "r = 1 + 2 + ... + n"
  22. ]
  23. },
  24. {
  25. "cell_type": "code",
  26. "execution_count": 3,
  27. "metadata": {},
  28. "outputs": [
  29. {
  30. "name": "stdout",
  31. "output_type": "stream",
  32. "text": [
  33. "enter a: 10\n",
  34. "enter b: 30\n"
  35. ]
  36. },
  37. {
  38. "data": {
  39. "text/plain": [
  40. "'1030'"
  41. ]
  42. },
  43. "execution_count": 3,
  44. "metadata": {},
  45. "output_type": "execute_result"
  46. }
  47. ],
  48. "source": [
  49. "a = input('enter a: ')\n",
  50. "b = input('enter b: ')\n",
  51. "c = a + b\n",
  52. "c"
  53. ]
  54. },
  55. {
  56. "cell_type": "markdown",
  57. "metadata": {},
  58. "source": [
  59. "# Lab 1.2\n",
  60. "เขียน program ที่เก็บค่าส่วนต่างๆ ของรถยนต์ คันหนึ่งเช่น width, height, length , color และ เป็นสีแดงให้ print \"I love it\" ถ้าไม่ Goodbye\n",
  61. "และถ้า width > 200 ให้ print \"very big car\""
  62. ]
  63. },
  64. {
  65. "cell_type": "code",
  66. "execution_count": 8,
  67. "metadata": {},
  68. "outputs": [
  69. {
  70. "name": "stdout",
  71. "output_type": "stream",
  72. "text": [
  73. "...\n",
  74. "I love it\n"
  75. ]
  76. }
  77. ],
  78. "source": [
  79. "car = {'w': 100, 'h':200, 'l':150, 'color': 'red'}\n",
  80. "for k in car:\n",
  81. " if k == 'color':\n",
  82. " if car[k] == \"red\":\n",
  83. " print(\"I love it\")\n",
  84. " else:\n",
  85. " print(\"Goodbye\")\n",
  86. " if k == \"w\":\n",
  87. " if car[k] > 200:\n",
  88. " print(\"Very big car\")\n",
  89. " else:\n",
  90. " print(\"...\")\n",
  91. " "
  92. ]
  93. }
  94. ],
  95. "metadata": {
  96. "kernelspec": {
  97. "display_name": "Python 3",
  98. "language": "python",
  99. "name": "python3"
  100. },
  101. "language_info": {
  102. "codemirror_mode": {
  103. "name": "ipython",
  104. "version": 3
  105. },
  106. "file_extension": ".py",
  107. "mimetype": "text/x-python",
  108. "name": "python",
  109. "nbconvert_exporter": "python",
  110. "pygments_lexer": "ipython3",
  111. "version": "3.8.5"
  112. }
  113. },
  114. "nbformat": 4,
  115. "nbformat_minor": 4
  116. }