Guest User

Untitled

a guest
Jan 19th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. {
  2. "cells": [
  3. {
  4. "cell_type": "code",
  5. "execution_count": 1,
  6. "metadata": {},
  7. "outputs": [
  8. {
  9. "data": {
  10. "text/plain": [
  11. "15"
  12. ]
  13. },
  14. "execution_count": 1,
  15. "metadata": {},
  16. "output_type": "execute_result"
  17. }
  18. ],
  19. "source": [
  20. "10 + 5 #足し算"
  21. ]
  22. },
  23. {
  24. "cell_type": "code",
  25. "execution_count": 2,
  26. "metadata": {},
  27. "outputs": [
  28. {
  29. "name": "stdout",
  30. "output_type": "stream",
  31. "text": [
  32. "Hello World\n"
  33. ]
  34. }
  35. ],
  36. "source": [
  37. "print('Hello World') #文字列を表示"
  38. ]
  39. },
  40. {
  41. "cell_type": "code",
  42. "execution_count": 4,
  43. "metadata": {},
  44. "outputs": [
  45. {
  46. "data": {
  47. "text/plain": [
  48. "'Hello'"
  49. ]
  50. },
  51. "execution_count": 4,
  52. "metadata": {},
  53. "output_type": "execute_result"
  54. }
  55. ],
  56. "source": [
  57. "word = 'Hello World' #変数に代入\n",
  58. "word[:5]       #先頭の5文字を表示"
  59. ]
  60. },
  61. {
  62. "cell_type": "code",
  63. "execution_count": 5,
  64. "metadata": {},
  65. "outputs": [
  66. {
  67. "name": "stdout",
  68. "output_type": "stream",
  69. "text": [
  70. "H\n",
  71. "e\n",
  72. "l\n",
  73. "l\n",
  74. "o\n",
  75. " \n",
  76. "W\n",
  77. "o\n",
  78. "r\n",
  79. "l\n",
  80. "d\n"
  81. ]
  82. }
  83. ],
  84. "source": [
  85. "for i in word: #一文字ずつ表示\n",
  86. " print(i)"
  87. ]
  88. },
  89. {
  90. "cell_type": "code",
  91. "execution_count": 6,
  92. "metadata": {},
  93. "outputs": [
  94. {
  95. "data": {
  96. "text/plain": [
  97. "'HELLO WORLD'"
  98. ]
  99. },
  100. "execution_count": 6,
  101. "metadata": {},
  102. "output_type": "execute_result"
  103. }
  104. ],
  105. "source": [
  106. "word.upper() #全て大文字に"
  107. ]
  108. },
  109. {
  110. "cell_type": "code",
  111. "execution_count": null,
  112. "metadata": {},
  113. "outputs": [],
  114. "source": []
  115. }
  116. ],
  117. "metadata": {
  118. "kernelspec": {
  119. "display_name": "Python 3",
  120. "language": "python",
  121. "name": "python3"
  122. },
  123. "language_info": {
  124. "codemirror_mode": {
  125. "name": "ipython",
  126. "version": 3
  127. },
  128. "file_extension": ".py",
  129. "mimetype": "text/x-python",
  130. "name": "python",
  131. "nbconvert_exporter": "python",
  132. "pygments_lexer": "ipython3",
  133. "version": "3.7.0"
  134. }
  135. },
  136. "nbformat": 4,
  137. "nbformat_minor": 2
  138. }
Add Comment
Please, Sign In to add comment