Advertisement
Guest User

Untitled

a guest
Sep 17th, 2019
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.64 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. "Hello, Python!\n"
  13. ]
  14. }
  15. ],
  16. "source": [
  17. "print('Hello, Python!')"
  18. ]
  19. },
  20. {
  21. "cell_type": "code",
  22. "execution_count": 2,
  23. "metadata": {},
  24. "outputs": [
  25. {
  26. "name": "stdout",
  27. "output_type": "stream",
  28. "text": [
  29. "3.6.7 | packaged by conda-forge | (default, Jul 2 2019, 02:18:42) \n",
  30. "[GCC 7.3.0]\n"
  31. ]
  32. }
  33. ],
  34. "source": [
  35. "import sys\n",
  36. "print(sys.version)"
  37. ]
  38. },
  39. {
  40. "cell_type": "code",
  41. "execution_count": null,
  42. "metadata": {},
  43. "outputs": [],
  44. "source": []
  45. },
  46. {
  47. "cell_type": "code",
  48. "execution_count": 3,
  49. "metadata": {},
  50. "outputs": [
  51. {
  52. "name": "stdout",
  53. "output_type": "stream",
  54. "text": [
  55. "Hello, Python!\n"
  56. ]
  57. }
  58. ],
  59. "source": [
  60. "print('Hello, Python!') # This line prints a string\n",
  61. "# print('Hi')"
  62. ]
  63. },
  64. {
  65. "cell_type": "code",
  66. "execution_count": 4,
  67. "metadata": {},
  68. "outputs": [
  69. {
  70. "ename": "NameError",
  71. "evalue": "name 'frint' is not defined",
  72. "output_type": "error",
  73. "traceback": [
  74. "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
  75. "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
  76. "\u001b[0;32m<ipython-input-4-92b84426a1cf>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mfrint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Hello, Python!\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
  77. "\u001b[0;31mNameError\u001b[0m: name 'frint' is not defined"
  78. ]
  79. }
  80. ],
  81. "source": [
  82. "frint(\"Hello, Python!\")"
  83. ]
  84. },
  85. {
  86. "cell_type": "code",
  87. "execution_count": 5,
  88. "metadata": {},
  89. "outputs": [
  90. {
  91. "name": "stdout",
  92. "output_type": "stream",
  93. "text": [
  94. "Hello, world!\n"
  95. ]
  96. }
  97. ],
  98. "source": [
  99. "print('Hello, world!')"
  100. ]
  101. },
  102. {
  103. "cell_type": "code",
  104. "execution_count": 6,
  105. "metadata": {},
  106. "outputs": [
  107. {
  108. "name": "stdout",
  109. "output_type": "stream",
  110. "text": [
  111. "Hello, world!\n"
  112. ]
  113. }
  114. ],
  115. "source": [
  116. "print('Hello, world!')\n",
  117. "# Print the traditional hello world"
  118. ]
  119. },
  120. {
  121. "cell_type": "code",
  122. "execution_count": 7,
  123. "metadata": {},
  124. "outputs": [
  125. {
  126. "data": {
  127. "text/plain": [
  128. "float"
  129. ]
  130. },
  131. "execution_count": 7,
  132. "metadata": {},
  133. "output_type": "execute_result"
  134. }
  135. ],
  136. "source": [
  137. "type(2.14)"
  138. ]
  139. },
  140. {
  141. "cell_type": "code",
  142. "execution_count": 8,
  143. "metadata": {},
  144. "outputs": [
  145. {
  146. "data": {
  147. "text/plain": [
  148. "float"
  149. ]
  150. },
  151. "execution_count": 8,
  152. "metadata": {},
  153. "output_type": "execute_result"
  154. }
  155. ],
  156. "source": [
  157. "type(2/2)"
  158. ]
  159. },
  160. {
  161. "cell_type": "code",
  162. "execution_count": 9,
  163. "metadata": {},
  164. "outputs": [
  165. {
  166. "name": "stdout",
  167. "output_type": "stream",
  168. "text": [
  169. "1.0\n"
  170. ]
  171. }
  172. ],
  173. "source": [
  174. "x=2/2\n",
  175. "print(x)"
  176. ]
  177. },
  178. {
  179. "cell_type": "code",
  180. "execution_count": 10,
  181. "metadata": {},
  182. "outputs": [
  183. {
  184. "data": {
  185. "text/plain": [
  186. "int"
  187. ]
  188. },
  189. "execution_count": 10,
  190. "metadata": {},
  191. "output_type": "execute_result"
  192. }
  193. ],
  194. "source": [
  195. "type(2)"
  196. ]
  197. },
  198. {
  199. "cell_type": "code",
  200. "execution_count": 11,
  201. "metadata": {},
  202. "outputs": [
  203. {
  204. "data": {
  205. "text/plain": [
  206. "2.0"
  207. ]
  208. },
  209. "execution_count": 11,
  210. "metadata": {},
  211. "output_type": "execute_result"
  212. }
  213. ],
  214. "source": [
  215. "float(2)"
  216. ]
  217. },
  218. {
  219. "cell_type": "code",
  220. "execution_count": 12,
  221. "metadata": {},
  222. "outputs": [
  223. {
  224. "ename": "ValueError",
  225. "evalue": "invalid literal for int() with base 10: '1 or 2 people'",
  226. "output_type": "error",
  227. "traceback": [
  228. "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
  229. "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)",
  230. "\u001b[0;32m<ipython-input-12-cd59a23aeda5>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'1 or 2 people'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
  231. "\u001b[0;31mValueError\u001b[0m: invalid literal for int() with base 10: '1 or 2 people'"
  232. ]
  233. }
  234. ],
  235. "source": [
  236. "int('1 or 2 people')"
  237. ]
  238. },
  239. {
  240. "cell_type": "code",
  241. "execution_count": 13,
  242. "metadata": {},
  243. "outputs": [
  244. {
  245. "data": {
  246. "text/plain": [
  247. "True"
  248. ]
  249. },
  250. "execution_count": 13,
  251. "metadata": {},
  252. "output_type": "execute_result"
  253. }
  254. ],
  255. "source": [
  256. "bool(1)"
  257. ]
  258. },
  259. {
  260. "cell_type": "code",
  261. "execution_count": 14,
  262. "metadata": {},
  263. "outputs": [
  264. {
  265. "data": {
  266. "text/plain": [
  267. "1"
  268. ]
  269. },
  270. "execution_count": 14,
  271. "metadata": {},
  272. "output_type": "execute_result"
  273. }
  274. ],
  275. "source": [
  276. "int(True)"
  277. ]
  278. },
  279. {
  280. "cell_type": "code",
  281. "execution_count": 15,
  282. "metadata": {},
  283. "outputs": [],
  284. "source": [
  285. "A = \"1\""
  286. ]
  287. },
  288. {
  289. "cell_type": "code",
  290. "execution_count": 16,
  291. "metadata": {},
  292. "outputs": [],
  293. "source": [
  294. "B = \"2\""
  295. ]
  296. },
  297. {
  298. "cell_type": "code",
  299. "execution_count": 17,
  300. "metadata": {},
  301. "outputs": [],
  302. "source": [
  303. "C=A+B"
  304. ]
  305. },
  306. {
  307. "cell_type": "code",
  308. "execution_count": 18,
  309. "metadata": {},
  310. "outputs": [
  311. {
  312. "ename": "NameError",
  313. "evalue": "name 'PRINT' is not defined",
  314. "output_type": "error",
  315. "traceback": [
  316. "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
  317. "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
  318. "\u001b[0;32m<ipython-input-18-086141036048>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mPRINT\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mC\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
  319. "\u001b[0;31mNameError\u001b[0m: name 'PRINT' is not defined"
  320. ]
  321. }
  322. ],
  323. "source": [
  324. "PRINT(C)"
  325. ]
  326. },
  327. {
  328. "cell_type": "code",
  329. "execution_count": 19,
  330. "metadata": {},
  331. "outputs": [
  332. {
  333. "ename": "NameError",
  334. "evalue": "name 'INT' is not defined",
  335. "output_type": "error",
  336. "traceback": [
  337. "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
  338. "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
  339. "\u001b[0;32m<ipython-input-19-65faa1e33f38>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mINT\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mC\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
  340. "\u001b[0;31mNameError\u001b[0m: name 'INT' is not defined"
  341. ]
  342. }
  343. ],
  344. "source": [
  345. "INT(C)"
  346. ]
  347. },
  348. {
  349. "cell_type": "code",
  350. "execution_count": 20,
  351. "metadata": {},
  352. "outputs": [],
  353. "source": [
  354. "C = A + B"
  355. ]
  356. },
  357. {
  358. "cell_type": "code",
  359. "execution_count": 21,
  360. "metadata": {},
  361. "outputs": [
  362. {
  363. "name": "stdout",
  364. "output_type": "stream",
  365. "text": [
  366. "ABC\n"
  367. ]
  368. }
  369. ],
  370. "source": [
  371. "D = \"ABCDEFG\"\n",
  372. "print(D[:3]) "
  373. ]
  374. },
  375. {
  376. "cell_type": "code",
  377. "execution_count": 22,
  378. "metadata": {},
  379. "outputs": [],
  380. "source": [
  381. "A = \"1\"\n",
  382. "B = \"2\"\n",
  383. "C = A + B\n"
  384. ]
  385. },
  386. {
  387. "cell_type": "code",
  388. "execution_count": 23,
  389. "metadata": {},
  390. "outputs": [
  391. {
  392. "name": "stdout",
  393. "output_type": "stream",
  394. "text": [
  395. "correct\n"
  396. ]
  397. }
  398. ],
  399. "source": [
  400. "E = 'clocrkr1e1c1t'\n",
  401. "print(E[::2])"
  402. ]
  403. },
  404. {
  405. "cell_type": "code",
  406. "execution_count": 24,
  407. "metadata": {},
  408. "outputs": [
  409. {
  410. "name": "stdout",
  411. "output_type": "stream",
  412. "text": [
  413. "\\\n"
  414. ]
  415. }
  416. ],
  417. "source": [
  418. "print(\"\\\\\")"
  419. ]
  420. },
  421. {
  422. "cell_type": "code",
  423. "execution_count": 25,
  424. "metadata": {},
  425. "outputs": [
  426. {
  427. "name": "stdout",
  428. "output_type": "stream",
  429. "text": [
  430. " \\ \n"
  431. ]
  432. }
  433. ],
  434. "source": [
  435. "print(r\" \\ \")"
  436. ]
  437. },
  438. {
  439. "cell_type": "code",
  440. "execution_count": 26,
  441. "metadata": {},
  442. "outputs": [
  443. {
  444. "data": {
  445. "text/plain": [
  446. "<function str.upper>"
  447. ]
  448. },
  449. "execution_count": 26,
  450. "metadata": {},
  451. "output_type": "execute_result"
  452. }
  453. ],
  454. "source": [
  455. "F = \"You are wrong\"\n",
  456. "F.upper"
  457. ]
  458. },
  459. {
  460. "cell_type": "code",
  461. "execution_count": 27,
  462. "metadata": {},
  463. "outputs": [
  464. {
  465. "data": {
  466. "text/plain": [
  467. "'YOU ARE WRONG'"
  468. ]
  469. },
  470. "execution_count": 27,
  471. "metadata": {},
  472. "output_type": "execute_result"
  473. }
  474. ],
  475. "source": [
  476. "F = \"You are wrong\"\n",
  477. "F.upper()"
  478. ]
  479. },
  480. {
  481. "cell_type": "code",
  482. "execution_count": 29,
  483. "metadata": {},
  484. "outputs": [
  485. {
  486. "data": {
  487. "text/plain": [
  488. "'Bob had a little lamb Little lamb, little lamb Bob had a little lamb Its fleece was white as snow And everywhere that Bob went Bob went, Bob went Everywhere that Bob went The lamb was sure to go'"
  489. ]
  490. },
  491. "execution_count": 29,
  492. "metadata": {},
  493. "output_type": "execute_result"
  494. }
  495. ],
  496. "source": [
  497. "G = \"Mary had a little lamb Little lamb, little lamb Mary had a little lamb \\\n",
  498. "Its fleece was white as snow And everywhere that Mary went Mary went, Mary went \\\n",
  499. "Everywhere that Mary went The lamb was sure to go\"\n",
  500. "G.find(\"snow\")\n",
  501. "G.replace(\"Mary\", \"Bob\")"
  502. ]
  503. },
  504. {
  505. "cell_type": "code",
  506. "execution_count": null,
  507. "metadata": {},
  508. "outputs": [],
  509. "source": []
  510. }
  511. ],
  512. "metadata": {
  513. "kernelspec": {
  514. "display_name": "Python",
  515. "language": "python",
  516. "name": "conda-env-python-py"
  517. },
  518. "language_info": {
  519. "codemirror_mode": {
  520. "name": "ipython",
  521. "version": 3
  522. },
  523. "file_extension": ".py",
  524. "mimetype": "text/x-python",
  525. "name": "python",
  526. "nbconvert_exporter": "python",
  527. "pygments_lexer": "ipython3",
  528. "version": "3.6.7"
  529. }
  530. },
  531. "nbformat": 4,
  532. "nbformat_minor": 4
  533. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement