|
1 | | -{ |
2 | | - "cells": [ |
3 | | - { |
4 | | - "cell_type": "markdown", |
5 | | - "metadata": {}, |
6 | | - "source": [ |
7 | | - "https://www.learnpython.org/" |
8 | | - ] |
9 | | - }, |
10 | | - { |
11 | | - "cell_type": "code", |
12 | | - "execution_count": 1, |
13 | | - "metadata": {}, |
14 | | - "outputs": [], |
15 | | - "source": [ |
16 | | - "def my_function():\n", |
17 | | - " print(\"Hello from my function!\")" |
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 | | - "Hello from my function!\n" |
30 | | - ] |
31 | | - } |
32 | | - ], |
33 | | - "source": [ |
34 | | - "my_function()" |
35 | | - ] |
36 | | - }, |
37 | | - { |
38 | | - "cell_type": "code", |
39 | | - "execution_count": 3, |
40 | | - "metadata": {}, |
41 | | - "outputs": [ |
42 | | - { |
43 | | - "name": "stdout", |
44 | | - "output_type": "stream", |
45 | | - "text": [ |
46 | | - "Hello test_username, from My Function!, I wish you test_greeting\n" |
47 | | - ] |
48 | | - } |
49 | | - ], |
50 | | - "source": [ |
51 | | - "def my_function_with_args(username, greeting):\n", |
52 | | - " print(\"Hello %s, from My Function!, I wish you %s\" %(username, greeting))\n", |
53 | | - " \n", |
54 | | - "my_function_with_args('test_username', 'test_greeting')" |
55 | | - ] |
56 | | - }, |
57 | | - { |
58 | | - "cell_type": "code", |
59 | | - "execution_count": 4, |
60 | | - "metadata": {}, |
61 | | - "outputs": [ |
62 | | - { |
63 | | - "name": "stdout", |
64 | | - "output_type": "stream", |
65 | | - "text": [ |
66 | | - "13\n" |
67 | | - ] |
68 | | - } |
69 | | - ], |
70 | | - "source": [ |
71 | | - "def sum_two_numbers(a, b):\n", |
72 | | - " return a + b\n", |
73 | | - "\n", |
74 | | - "sum_of_numbers = sum_two_numbers(6, 7)\n", |
75 | | - "print(sum_of_numbers)" |
76 | | - ] |
77 | | - }, |
78 | | - { |
79 | | - "cell_type": "code", |
80 | | - "execution_count": 5, |
81 | | - "metadata": {}, |
82 | | - "outputs": [], |
83 | | - "source": [ |
84 | | - "def list_benefits():\n", |
85 | | - " return[]\n", |
86 | | - "\n", |
87 | | - "def build_sentence(benefit):\n", |
88 | | - " return \"\"\n", |
89 | | - "\n", |
90 | | - "def name_the_benefits_of_functions():\n", |
91 | | - " list_of_benefits = list_benefits()\n", |
92 | | - " for benefit in list_of_benefits:\n", |
93 | | - " print(build_sentence(benefit))\n", |
94 | | - " \n", |
95 | | - "name_the_benefits_of_functions()" |
96 | | - ] |
97 | | - }, |
98 | | - { |
99 | | - "cell_type": "code", |
100 | | - "execution_count": 14, |
101 | | - "metadata": {}, |
102 | | - "outputs": [ |
103 | | - { |
104 | | - "name": "stdout", |
105 | | - "output_type": "stream", |
106 | | - "text": [ |
107 | | - "This is a message inside the class.\n", |
108 | | - "blah\n" |
109 | | - ] |
110 | | - } |
111 | | - ], |
112 | | - "source": [ |
113 | | - "class MyClass:\n", |
114 | | - " variable = \"blah\"\n", |
115 | | - " \n", |
116 | | - " def function(self):\n", |
117 | | - " print(\"This is a message inside the class.\")\n", |
118 | | - " \n", |
119 | | - "myobjectx = MyClass()\n", |
120 | | - "\n", |
121 | | - "myobjectx.function()\n", |
122 | | - "print(myobjectx.variable)" |
123 | | - ] |
124 | | - }, |
125 | | - { |
126 | | - "cell_type": "code", |
127 | | - "execution_count": null, |
128 | | - "metadata": {}, |
129 | | - "outputs": [], |
130 | | - "source": [] |
131 | | - } |
132 | | - ], |
133 | | - "metadata": { |
134 | | - "kernelspec": { |
135 | | - "display_name": "Python 3.8.10 64-bit", |
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.10" |
150 | | - }, |
151 | | - "orig_nbformat": 4, |
152 | | - "vscode": { |
153 | | - "interpreter": { |
154 | | - "hash": "31f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6" |
155 | | - } |
156 | | - } |
157 | | - }, |
158 | | - "nbformat": 4, |
159 | | - "nbformat_minor": 2 |
160 | | -} |
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "metadata": {}, |
| 6 | + "source": [ |
| 7 | + "https://www.learnpython.org/" |
| 8 | + ] |
| 9 | + }, |
| 10 | + { |
| 11 | + "cell_type": "code", |
| 12 | + "execution_count": 1, |
| 13 | + "metadata": {}, |
| 14 | + "outputs": [], |
| 15 | + "source": [ |
| 16 | + "def my_function():\n", |
| 17 | + " print(\"Hello from my function!\")" |
| 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 | + "Hello from my function!\n" |
| 30 | + ] |
| 31 | + } |
| 32 | + ], |
| 33 | + "source": [ |
| 34 | + "my_function()" |
| 35 | + ] |
| 36 | + }, |
| 37 | + { |
| 38 | + "cell_type": "code", |
| 39 | + "execution_count": 3, |
| 40 | + "metadata": {}, |
| 41 | + "outputs": [ |
| 42 | + { |
| 43 | + "name": "stdout", |
| 44 | + "output_type": "stream", |
| 45 | + "text": [ |
| 46 | + "Hello test_username, from My Function!, I wish you test_greeting\n" |
| 47 | + ] |
| 48 | + } |
| 49 | + ], |
| 50 | + "source": [ |
| 51 | + "def my_function_with_args(username, greeting):\n", |
| 52 | + " print(\"Hello %s, from My Function!, I wish you %s\" %(username, greeting))\n", |
| 53 | + " \n", |
| 54 | + "my_function_with_args('test_username', 'test_greeting')" |
| 55 | + ] |
| 56 | + }, |
| 57 | + { |
| 58 | + "cell_type": "code", |
| 59 | + "execution_count": 4, |
| 60 | + "metadata": {}, |
| 61 | + "outputs": [ |
| 62 | + { |
| 63 | + "name": "stdout", |
| 64 | + "output_type": "stream", |
| 65 | + "text": [ |
| 66 | + "13\n" |
| 67 | + ] |
| 68 | + } |
| 69 | + ], |
| 70 | + "source": [ |
| 71 | + "def sum_two_numbers(a, b):\n", |
| 72 | + " return a + b\n", |
| 73 | + "\n", |
| 74 | + "sum_of_numbers = sum_two_numbers(6, 7)\n", |
| 75 | + "print(sum_of_numbers)" |
| 76 | + ] |
| 77 | + }, |
| 78 | + { |
| 79 | + "cell_type": "code", |
| 80 | + "execution_count": 5, |
| 81 | + "metadata": {}, |
| 82 | + "outputs": [], |
| 83 | + "source": [ |
| 84 | + "def list_benefits():\n", |
| 85 | + " return[]\n", |
| 86 | + "\n", |
| 87 | + "def build_sentence(benefit):\n", |
| 88 | + " return \"\"\n", |
| 89 | + "\n", |
| 90 | + "def name_the_benefits_of_functions():\n", |
| 91 | + " list_of_benefits = list_benefits()\n", |
| 92 | + " for benefit in list_of_benefits:\n", |
| 93 | + " print(build_sentence(benefit))\n", |
| 94 | + " \n", |
| 95 | + "name_the_benefits_of_functions()" |
| 96 | + ] |
| 97 | + }, |
| 98 | + { |
| 99 | + "cell_type": "code", |
| 100 | + "execution_count": 14, |
| 101 | + "metadata": {}, |
| 102 | + "outputs": [ |
| 103 | + { |
| 104 | + "name": "stdout", |
| 105 | + "output_type": "stream", |
| 106 | + "text": [ |
| 107 | + "This is a message inside the class.\n", |
| 108 | + "blah\n" |
| 109 | + ] |
| 110 | + } |
| 111 | + ], |
| 112 | + "source": [ |
| 113 | + "class MyClass:\n", |
| 114 | + " variable = \"blah\"\n", |
| 115 | + " \n", |
| 116 | + " def function(self):\n", |
| 117 | + " print(\"This is a message inside the class.\")\n", |
| 118 | + " \n", |
| 119 | + "myobjectx = MyClass()\n", |
| 120 | + "\n", |
| 121 | + "myobjectx.function()\n", |
| 122 | + "print(myobjectx.variable)" |
| 123 | + ] |
| 124 | + }, |
| 125 | + { |
| 126 | + "cell_type": "code", |
| 127 | + "execution_count": null, |
| 128 | + "metadata": {}, |
| 129 | + "outputs": [], |
| 130 | + "source": [] |
| 131 | + } |
| 132 | + ], |
| 133 | + "metadata": { |
| 134 | + "kernelspec": { |
| 135 | + "display_name": "Python 3.8.10 64-bit", |
| 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.10" |
| 150 | + }, |
| 151 | + "orig_nbformat": 4, |
| 152 | + "vscode": { |
| 153 | + "interpreter": { |
| 154 | + "hash": "31f2aee4e71d21fbe5cf8b01ff0e069b9275f58929596ceb00d14d90e3e16cd6" |
| 155 | + } |
| 156 | + } |
| 157 | + }, |
| 158 | + "nbformat": 4, |
| 159 | + "nbformat_minor": 2 |
| 160 | +} |
0 commit comments