Bez popisu

Untitled.ipynb 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. {
  2. "cells": [
  3. {
  4. "cell_type": "code",
  5. "execution_count": 1,
  6. "metadata": {},
  7. "outputs": [
  8. {
  9. "name": "stdout",
  10. "output_type": "stream",
  11. "text": [
  12. "Happy 23rd Birthday!\n"
  13. ]
  14. }
  15. ],
  16. "source": [
  17. "age = 23\n",
  18. "message = \"Happy \" + str(age) + \"rd Birthday!\"\n",
  19. "\n",
  20. "print(message)"
  21. ]
  22. },
  23. {
  24. "cell_type": "code",
  25. "execution_count": 4,
  26. "metadata": {},
  27. "outputs": [
  28. {
  29. "name": "stdout",
  30. "output_type": "stream",
  31. "text": [
  32. "Hello, Ada Lovelace!\n"
  33. ]
  34. }
  35. ],
  36. "source": [
  37. "# %load chapter_02/name.py\n",
  38. "first_name = \"ada\"\n",
  39. "last_name = \"lovelace\"\n",
  40. "full_name = first_name + \" \" + last_name\n",
  41. "\n",
  42. "message = \"Hello, \" + full_name.title() + \"!\"\n",
  43. "print(message)\n"
  44. ]
  45. },
  46. {
  47. "cell_type": "code",
  48. "execution_count": null,
  49. "metadata": {},
  50. "outputs": [],
  51. "source": []
  52. },
  53. {
  54. "cell_type": "code",
  55. "execution_count": null,
  56. "metadata": {},
  57. "outputs": [],
  58. "source": []
  59. },
  60. {
  61. "cell_type": "code",
  62. "execution_count": 2,
  63. "metadata": {},
  64. "outputs": [
  65. {
  66. "data": {
  67. "text/plain": [
  68. "14"
  69. ]
  70. },
  71. "execution_count": 2,
  72. "metadata": {},
  73. "output_type": "execute_result"
  74. }
  75. ],
  76. "source": [
  77. "def sum(a,b):\n",
  78. " return a + b\n",
  79. "sum(12,2)"
  80. ]
  81. },
  82. {
  83. "cell_type": "code",
  84. "execution_count": 5,
  85. "metadata": {},
  86. "outputs": [
  87. {
  88. "name": "stdout",
  89. "output_type": "stream",
  90. "text": [
  91. "['honda', 'yamaha', 'suzuki', 'ducati']\n",
  92. "['honda', 'yamaha', 'suzuki']\n",
  93. "\n",
  94. "A Ducati is too expensive for me.\n"
  95. ]
  96. }
  97. ],
  98. "source": [
  99. "motorcycles = ['honda', 'yamaha', 'suzuki', 'ducati'] \n",
  100. "print(motorcycles)\n",
  101. "\n",
  102. "too_expensive = 'ducati'\n",
  103. "motorcycles.remove(too_expensive)\n",
  104. "print(motorcycles)\n",
  105. "print(\"\\nA \" + too_expensive.title() + \" is too expensive for me.\")\n"
  106. ]
  107. },
  108. {
  109. "cell_type": "code",
  110. "execution_count": 6,
  111. "metadata": {},
  112. "outputs": [
  113. {
  114. "name": "stdout",
  115. "output_type": "stream",
  116. "text": [
  117. "['dog', 'cat', 'dog', 'goldfish', 'cat', 'rabbit', 'cat']\n",
  118. "['dog', 'dog', 'goldfish', 'rabbit']\n"
  119. ]
  120. }
  121. ],
  122. "source": [
  123. "pets = ['dog', 'cat', 'dog', 'goldfish', 'cat', 'rabbit', 'cat']\n",
  124. "print(pets)\n",
  125. "\n",
  126. "while 'cat' in pets:\n",
  127. " pets.remove('cat')\n",
  128. " \n",
  129. "print(pets)\n"
  130. ]
  131. }
  132. ],
  133. "metadata": {
  134. "kernelspec": {
  135. "display_name": "Python 3",
  136. "language": "python",
  137. "name": "python3"
  138. },
  139. "language_info": {
  140. "codemirror_mode": {
  141. "name": "ipython",
  142. "version": 3
  143. },
  144. "file_extension": ".py",
  145. "mimetype": "text/x-python",
  146. "name": "python",
  147. "nbconvert_exporter": "python",
  148. "pygments_lexer": "ipython3",
  149. "version": "3.8.5"
  150. }
  151. },
  152. "nbformat": 4,
  153. "nbformat_minor": 4
  154. }