Advertisement
Guest User

Untitled

a guest
Jul 19th, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.70 KB | None | 0 0
  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. "Michael Jackson\n"
  13. ]
  14. }
  15. ],
  16. "source": [
  17. "Name=\"Michael Jackson\"\n",
  18. "print(Name)"
  19. ]
  20. },
  21. {
  22. "cell_type": "code",
  23. "execution_count": 2,
  24. "metadata": {},
  25. "outputs": [
  26. {
  27. "name": "stdout",
  28. "output_type": "stream",
  29. "text": [
  30. "Michae\n"
  31. ]
  32. }
  33. ],
  34. "source": [
  35. "print(Name[0:6])"
  36. ]
  37. },
  38. {
  39. "cell_type": "code",
  40. "execution_count": 3,
  41. "metadata": {},
  42. "outputs": [
  43. {
  44. "data": {
  45. "text/plain": [
  46. "15"
  47. ]
  48. },
  49. "execution_count": 3,
  50. "metadata": {},
  51. "output_type": "execute_result"
  52. }
  53. ],
  54. "source": [
  55. "len(Name)"
  56. ]
  57. },
  58. {
  59. "cell_type": "code",
  60. "execution_count": 4,
  61. "metadata": {},
  62. "outputs": [
  63. {
  64. "name": "stdout",
  65. "output_type": "stream",
  66. "text": [
  67. "Michael JacksonMichael JacksonMichael Jackson\n"
  68. ]
  69. }
  70. ],
  71. "source": [
  72. "print(3*Name)"
  73. ]
  74. },
  75. {
  76. "cell_type": "code",
  77. "execution_count": 5,
  78. "metadata": {},
  79. "outputs": [
  80. {
  81. "name": "stdout",
  82. "output_type": "stream",
  83. "text": [
  84. "Michael\n"
  85. ]
  86. }
  87. ],
  88. "source": [
  89. "print(Name[0:7])"
  90. ]
  91. },
  92. {
  93. "cell_type": "code",
  94. "execution_count": 6,
  95. "metadata": {},
  96. "outputs": [
  97. {
  98. "data": {
  99. "text/plain": [
  100. "'ackson'"
  101. ]
  102. },
  103. "execution_count": 6,
  104. "metadata": {},
  105. "output_type": "execute_result"
  106. }
  107. ],
  108. "source": [
  109. "Name[9:15]"
  110. ]
  111. },
  112. {
  113. "cell_type": "code",
  114. "execution_count": 7,
  115. "metadata": {},
  116. "outputs": [
  117. {
  118. "data": {
  119. "text/plain": [
  120. "'Jackson'"
  121. ]
  122. },
  123. "execution_count": 7,
  124. "metadata": {},
  125. "output_type": "execute_result"
  126. }
  127. ],
  128. "source": [
  129. "Name[8:15]"
  130. ]
  131. },
  132. {
  133. "cell_type": "code",
  134. "execution_count": 8,
  135. "metadata": {},
  136. "outputs": [],
  137. "source": [
  138. "Name=Name+\"is best\""
  139. ]
  140. },
  141. {
  142. "cell_type": "code",
  143. "execution_count": 9,
  144. "metadata": {},
  145. "outputs": [
  146. {
  147. "data": {
  148. "text/plain": [
  149. "'Michael Jacksonis best'"
  150. ]
  151. },
  152. "execution_count": 9,
  153. "metadata": {},
  154. "output_type": "execute_result"
  155. }
  156. ],
  157. "source": [
  158. "Name"
  159. ]
  160. },
  161. {
  162. "cell_type": "code",
  163. "execution_count": 10,
  164. "metadata": {},
  165. "outputs": [
  166. {
  167. "ename": "TypeError",
  168. "evalue": "unsupported operand type(s) for -: 'str' and 'str'",
  169. "output_type": "error",
  170. "traceback": [
  171. "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
  172. "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)",
  173. "\u001b[0;32m<ipython-input-10-8afeb26ac5ff>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mName\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mName\u001b[0m\u001b[0;34m-\u001b[0m\u001b[0;34m\"is\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
  174. "\u001b[0;31mTypeError\u001b[0m: unsupported operand type(s) for -: 'str' and 'str'"
  175. ]
  176. }
  177. ],
  178. "source": [
  179. "Name=Name-\"is\""
  180. ]
  181. },
  182. {
  183. "cell_type": "code",
  184. "execution_count": 11,
  185. "metadata": {},
  186. "outputs": [
  187. {
  188. "ename": "TypeError",
  189. "evalue": "unsupported operand type(s) for -: 'str' and 'str'",
  190. "output_type": "error",
  191. "traceback": [
  192. "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
  193. "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)",
  194. "\u001b[0;32m<ipython-input-11-65cfe13151ba>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mName\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mName\u001b[0m\u001b[0;34m-\u001b[0m\u001b[0;34m\"best\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
  195. "\u001b[0;31mTypeError\u001b[0m: unsupported operand type(s) for -: 'str' and 'str'"
  196. ]
  197. }
  198. ],
  199. "source": [
  200. "Name=Name-\"best\""
  201. ]
  202. },
  203. {
  204. "cell_type": "code",
  205. "execution_count": 12,
  206. "metadata": {},
  207. "outputs": [
  208. {
  209. "name": "stdout",
  210. "output_type": "stream",
  211. "text": [
  212. "YO MAN\n"
  213. ]
  214. }
  215. ],
  216. "source": [
  217. "A=\"Yo Man\"\n",
  218. "B=A.upper()\n",
  219. "print(B)"
  220. ]
  221. },
  222. {
  223. "cell_type": "code",
  224. "execution_count": 13,
  225. "metadata": {},
  226. "outputs": [],
  227. "source": [
  228. "B=A.replace(\"Man\", \"Girl\")"
  229. ]
  230. },
  231. {
  232. "cell_type": "code",
  233. "execution_count": 14,
  234. "metadata": {},
  235. "outputs": [
  236. {
  237. "data": {
  238. "text/plain": [
  239. "'Yo Girl'"
  240. ]
  241. },
  242. "execution_count": 14,
  243. "metadata": {},
  244. "output_type": "execute_result"
  245. }
  246. ],
  247. "source": [
  248. "B"
  249. ]
  250. },
  251. {
  252. "cell_type": "code",
  253. "execution_count": 15,
  254. "metadata": {},
  255. "outputs": [],
  256. "source": [
  257. "Name=(\"is best\", \"\")"
  258. ]
  259. },
  260. {
  261. "cell_type": "code",
  262. "execution_count": 16,
  263. "metadata": {},
  264. "outputs": [
  265. {
  266. "data": {
  267. "text/plain": [
  268. "('is best', '')"
  269. ]
  270. },
  271. "execution_count": 16,
  272. "metadata": {},
  273. "output_type": "execute_result"
  274. }
  275. ],
  276. "source": [
  277. "Name"
  278. ]
  279. },
  280. {
  281. "cell_type": "code",
  282. "execution_count": 17,
  283. "metadata": {},
  284. "outputs": [],
  285. "source": [
  286. "Name=\"Michael Jackson is best\"\n",
  287. "Name=Name.replace(\"is best\", \"\")"
  288. ]
  289. },
  290. {
  291. "cell_type": "code",
  292. "execution_count": 18,
  293. "metadata": {},
  294. "outputs": [
  295. {
  296. "data": {
  297. "text/plain": [
  298. "'Michael Jackson '"
  299. ]
  300. },
  301. "execution_count": 18,
  302. "metadata": {},
  303. "output_type": "execute_result"
  304. }
  305. ],
  306. "source": [
  307. "Name"
  308. ]
  309. },
  310. {
  311. "cell_type": "code",
  312. "execution_count": 19,
  313. "metadata": {},
  314. "outputs": [
  315. {
  316. "data": {
  317. "text/plain": [
  318. "1"
  319. ]
  320. },
  321. "execution_count": 19,
  322. "metadata": {},
  323. "output_type": "execute_result"
  324. }
  325. ],
  326. "source": [
  327. "n=\"abcde\"\n",
  328. "n.find(\"b\")\n"
  329. ]
  330. },
  331. {
  332. "cell_type": "code",
  333. "execution_count": null,
  334. "metadata": {},
  335. "outputs": [],
  336. "source": []
  337. }
  338. ],
  339. "metadata": {
  340. "kernelspec": {
  341. "display_name": "Python 3",
  342. "language": "python",
  343. "name": "python3"
  344. },
  345. "language_info": {
  346. "codemirror_mode": {
  347. "name": "ipython",
  348. "version": 3
  349. },
  350. "file_extension": ".py",
  351. "mimetype": "text/x-python",
  352. "name": "python",
  353. "nbconvert_exporter": "python",
  354. "pygments_lexer": "ipython3",
  355. "version": "3.6.8"
  356. }
  357. },
  358. "nbformat": 4,
  359. "nbformat_minor": 2
  360. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement