|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "id": "59228d48-c915-497a-847d-acf1601f3381", |
| 6 | + "metadata": {}, |
| 7 | + "source": [ |
| 8 | + "## Python print() Function" |
| 9 | + ] |
| 10 | + }, |
| 11 | + { |
| 12 | + "cell_type": "markdown", |
| 13 | + "id": "bbf1636b-0dfc-4481-a871-55cc8f873b2d", |
| 14 | + "metadata": {}, |
| 15 | + "source": [ |
| 16 | + "The print() function in Python is used to output text or other data to the console. It takes one or more arguments, which can be of any data type, and prints them to the console.\n", |
| 17 | + "\n", |
| 18 | + "The basic syntax of print() is:<br>\n", |
| 19 | + "**print(object(s), sep=separator, end=end, file=file, flush=flush)**\n", |
| 20 | + "\n", |
| 21 | + "* object(s): One or more objects to print. This can be a string, a variable, or any otherobject.\n", |
| 22 | + "* sep: Separator between the objects to be printed. By default, it is a space character.\n", |
| 23 | + "* end: The character to be printed at the end of the statement. By default, it is a newline character.\n", |
| 24 | + "* file: Output stream to which the text will be printed. By default, it is the console.\n", |
| 25 | + "* flush: A Boolean value that specifies whether to flush the output buffer. By default, it is False." |
| 26 | + ] |
| 27 | + }, |
| 28 | + { |
| 29 | + "cell_type": "code", |
| 30 | + "execution_count": 1, |
| 31 | + "id": "bee72125-bc56-42cf-bf42-aec71bcb1182", |
| 32 | + "metadata": { |
| 33 | + "tags": [] |
| 34 | + }, |
| 35 | + "outputs": [ |
| 36 | + { |
| 37 | + "name": "stdout", |
| 38 | + "output_type": "stream", |
| 39 | + "text": [ |
| 40 | + "Hello World\n" |
| 41 | + ] |
| 42 | + } |
| 43 | + ], |
| 44 | + "source": [ |
| 45 | + "print(\"Hello World\")" |
| 46 | + ] |
| 47 | + }, |
| 48 | + { |
| 49 | + "cell_type": "code", |
| 50 | + "execution_count": 2, |
| 51 | + "id": "ba3bf44e-5fc8-4c11-aa0e-fc8eda0a97b7", |
| 52 | + "metadata": { |
| 53 | + "tags": [] |
| 54 | + }, |
| 55 | + "outputs": [ |
| 56 | + { |
| 57 | + "name": "stdout", |
| 58 | + "output_type": "stream", |
| 59 | + "text": [ |
| 60 | + "Hello, GIS lovers!\n" |
| 61 | + ] |
| 62 | + } |
| 63 | + ], |
| 64 | + "source": [ |
| 65 | + "print(\"Hello, GIS lovers!\")" |
| 66 | + ] |
| 67 | + }, |
| 68 | + { |
| 69 | + "cell_type": "code", |
| 70 | + "execution_count": 3, |
| 71 | + "id": "439c7f4f-a27a-412e-8722-b286490ef0a6", |
| 72 | + "metadata": { |
| 73 | + "tags": [] |
| 74 | + }, |
| 75 | + "outputs": [ |
| 76 | + { |
| 77 | + "name": "stdout", |
| 78 | + "output_type": "stream", |
| 79 | + "text": [ |
| 80 | + "GeoNext is best for GIS content\n" |
| 81 | + ] |
| 82 | + } |
| 83 | + ], |
| 84 | + "source": [ |
| 85 | + "print(\"GeoNext is best for GIS content\")" |
| 86 | + ] |
| 87 | + }, |
| 88 | + { |
| 89 | + "cell_type": "markdown", |
| 90 | + "id": "2ec71a0c-31f7-4454-8e3f-e1113faeefad", |
| 91 | + "metadata": {}, |
| 92 | + "source": [ |
| 93 | + "### Printing more than one object" |
| 94 | + ] |
| 95 | + }, |
| 96 | + { |
| 97 | + "cell_type": "code", |
| 98 | + "execution_count": 4, |
| 99 | + "id": "e7d2b923-860c-4afd-99a2-1e38c017f965", |
| 100 | + "metadata": { |
| 101 | + "tags": [] |
| 102 | + }, |
| 103 | + "outputs": [ |
| 104 | + { |
| 105 | + "name": "stdout", |
| 106 | + "output_type": "stream", |
| 107 | + "text": [ |
| 108 | + "Hello How are you?\n" |
| 109 | + ] |
| 110 | + } |
| 111 | + ], |
| 112 | + "source": [ |
| 113 | + "print(\"Hello\", \"How are you?\")" |
| 114 | + ] |
| 115 | + }, |
| 116 | + { |
| 117 | + "cell_type": "code", |
| 118 | + "execution_count": 5, |
| 119 | + "id": "b7afda26-35ce-444f-9b47-d096c16c5823", |
| 120 | + "metadata": { |
| 121 | + "tags": [] |
| 122 | + }, |
| 123 | + "outputs": [ |
| 124 | + { |
| 125 | + "name": "stdout", |
| 126 | + "output_type": "stream", |
| 127 | + "text": [ |
| 128 | + "5 10\n" |
| 129 | + ] |
| 130 | + } |
| 131 | + ], |
| 132 | + "source": [ |
| 133 | + "a = 5\n", |
| 134 | + "b = 10\n", |
| 135 | + "print(a, b)" |
| 136 | + ] |
| 137 | + }, |
| 138 | + { |
| 139 | + "cell_type": "markdown", |
| 140 | + "id": "c26f0daa-30a2-4585-8789-fdb7e6ed44d2", |
| 141 | + "metadata": { |
| 142 | + "tags": [] |
| 143 | + }, |
| 144 | + "source": [ |
| 145 | + "### Python end parameter in print()" |
| 146 | + ] |
| 147 | + }, |
| 148 | + { |
| 149 | + "cell_type": "code", |
| 150 | + "execution_count": 8, |
| 151 | + "id": "bfbb75b0-a02a-425b-8ef6-60ce3d9eeada", |
| 152 | + "metadata": { |
| 153 | + "tags": [] |
| 154 | + }, |
| 155 | + "outputs": [ |
| 156 | + { |
| 157 | + "name": "stdout", |
| 158 | + "output_type": "stream", |
| 159 | + "text": [ |
| 160 | + "Welcome to GeoNext\n" |
| 161 | + ] |
| 162 | + } |
| 163 | + ], |
| 164 | + "source": [ |
| 165 | + "print(\"Welcome to\", end=\" \")\n", |
| 166 | + "print(\"GeoNext\")" |
| 167 | + ] |
| 168 | + }, |
| 169 | + { |
| 170 | + "cell_type": "code", |
| 171 | + "execution_count": 9, |
| 172 | + "id": "b62587fe-1c0d-4206-822e-0eea3689b0bd", |
| 173 | + "metadata": { |
| 174 | + "tags": [] |
| 175 | + }, |
| 176 | + "outputs": [ |
| 177 | + { |
| 178 | + "name": "stdout", |
| 179 | + "output_type": "stream", |
| 180 | + "text": [ |
| 181 | + "Follow @GeoNext\n" |
| 182 | + ] |
| 183 | + } |
| 184 | + ], |
| 185 | + "source": [ |
| 186 | + "print(\"Follow \", end=\"@\")\n", |
| 187 | + "print(\"GeoNext\")" |
| 188 | + ] |
| 189 | + }, |
| 190 | + { |
| 191 | + "cell_type": "markdown", |
| 192 | + "id": "3d822b42-56ac-4d23-a22d-3ced39bd189c", |
| 193 | + "metadata": { |
| 194 | + "tags": [] |
| 195 | + }, |
| 196 | + "source": [ |
| 197 | + "### Python sep parameter in print()" |
| 198 | + ] |
| 199 | + }, |
| 200 | + { |
| 201 | + "cell_type": "code", |
| 202 | + "execution_count": 12, |
| 203 | + "id": "dd04ba37-389e-4a3b-8060-b64017fb95ff", |
| 204 | + "metadata": { |
| 205 | + "tags": [] |
| 206 | + }, |
| 207 | + "outputs": [ |
| 208 | + { |
| 209 | + "name": "stdout", |
| 210 | + "output_type": "stream", |
| 211 | + "text": [ |
| 212 | + "09-03-2023\n" |
| 213 | + ] |
| 214 | + } |
| 215 | + ], |
| 216 | + "source": [ |
| 217 | + "print(\"09\", \"03\", \"2023\", sep=\"-\")" |
| 218 | + ] |
| 219 | + }, |
| 220 | + { |
| 221 | + "cell_type": "code", |
| 222 | + "execution_count": 14, |
| 223 | + "id": "3c47de24-9958-4d96-a9b5-7d17be6c5b23", |
| 224 | + "metadata": { |
| 225 | + "tags": [] |
| 226 | + }, |
| 227 | + "outputs": [ |
| 228 | + { |
| 229 | + "name": "stdout", |
| 230 | + "output_type": "stream", |
| 231 | + "text": [ |
| 232 | + "krish@GeoNext\n" |
| 233 | + ] |
| 234 | + } |
| 235 | + ], |
| 236 | + "source": [ |
| 237 | + "print(\"krish\", \"GeoNext\", sep=\"@\")" |
| 238 | + ] |
| 239 | + }, |
| 240 | + { |
| 241 | + "cell_type": "markdown", |
| 242 | + "id": "c2e00b2f-762e-4499-8241-73c22aa66d09", |
| 243 | + "metadata": { |
| 244 | + "tags": [] |
| 245 | + }, |
| 246 | + "source": [ |
| 247 | + "### String Concatenation" |
| 248 | + ] |
| 249 | + }, |
| 250 | + { |
| 251 | + "cell_type": "code", |
| 252 | + "execution_count": 18, |
| 253 | + "id": "034ac18d-0c31-456a-b26e-2771ed2c9195", |
| 254 | + "metadata": { |
| 255 | + "tags": [] |
| 256 | + }, |
| 257 | + "outputs": [ |
| 258 | + { |
| 259 | + "name": "stdout", |
| 260 | + "output_type": "stream", |
| 261 | + "text": [ |
| 262 | + "abc\n" |
| 263 | + ] |
| 264 | + } |
| 265 | + ], |
| 266 | + "source": [ |
| 267 | + "print(\"a\"+\"bc\")" |
| 268 | + ] |
| 269 | + }, |
| 270 | + { |
| 271 | + "cell_type": "code", |
| 272 | + "execution_count": 17, |
| 273 | + "id": "fe5fd244-6d94-45ff-a518-263ea10efe83", |
| 274 | + "metadata": { |
| 275 | + "tags": [] |
| 276 | + }, |
| 277 | + "outputs": [ |
| 278 | + { |
| 279 | + "name": "stdout", |
| 280 | + "output_type": "stream", |
| 281 | + "text": [ |
| 282 | + "GeoNext\n" |
| 283 | + ] |
| 284 | + } |
| 285 | + ], |
| 286 | + "source": [ |
| 287 | + "print(\"Geo\" + \"Next\")" |
| 288 | + ] |
| 289 | + } |
| 290 | + ], |
| 291 | + "metadata": { |
| 292 | + "kernelspec": { |
| 293 | + "display_name": "Python 3 (ipykernel)", |
| 294 | + "language": "python", |
| 295 | + "name": "python3" |
| 296 | + }, |
| 297 | + "language_info": { |
| 298 | + "codemirror_mode": { |
| 299 | + "name": "ipython", |
| 300 | + "version": 3 |
| 301 | + }, |
| 302 | + "file_extension": ".py", |
| 303 | + "mimetype": "text/x-python", |
| 304 | + "name": "python", |
| 305 | + "nbconvert_exporter": "python", |
| 306 | + "pygments_lexer": "ipython3", |
| 307 | + "version": "3.11.2" |
| 308 | + } |
| 309 | + }, |
| 310 | + "nbformat": 4, |
| 311 | + "nbformat_minor": 5 |
| 312 | +} |
0 commit comments