├── Arrays_in_Python
└── Code
├── Basic_Python_by_Kousar_Raza.ipynb
├── DataType and Variables
├── Day_1(Introduction_to_Python).ipynb
├── Day_1.ipynb
├── Day_2(Python_Comments_&_Keywords).ipynb
├── Day_2.ipynb
├── Day_3_(Python_Variables).ipynb
├── Day_4(Data_Types_&_Type_Casting).ipynb
├── Day_5(Python_Operators).ipynb
├── Exercise
└── Temperature_Conventers
│ ├── Celsius_to_Fahrenheit
│ ├── CelsiustoFahrenheit.py
│ └── FahrenheittoCelsicus.py
├── Operators in Python
├── Arithmetic Operators
│ └── aaa
├── Assignment operators
│ └── ath
└── Comparison operators
│ └── asa
└── README.md
/Arrays_in_Python/Code:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/Basic_Python_by_Kousar_Raza.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "nbformat": 4,
3 | "nbformat_minor": 0,
4 | "metadata": {
5 | "colab": {
6 | "provenance": [],
7 | "toc_visible": true,
8 | "collapsed_sections": [
9 | "2-vyAn3N-Uuz"
10 | ],
11 | "authorship_tag": "ABX9TyOlnKwu6/D7BgxKVZj3sCE+",
12 | "include_colab_link": true
13 | },
14 | "kernelspec": {
15 | "name": "python3",
16 | "display_name": "Python 3"
17 | },
18 | "language_info": {
19 | "name": "python"
20 | }
21 | },
22 | "cells": [
23 | {
24 | "cell_type": "markdown",
25 | "metadata": {
26 | "id": "view-in-github",
27 | "colab_type": "text"
28 | },
29 | "source": [
30 | "
"
31 | ]
32 | },
33 | {
34 | "cell_type": "markdown",
35 | "source": [
36 | "#Day-1\n"
37 | ],
38 | "metadata": {
39 | "id": "X6HJjQ3eqaym"
40 | }
41 | },
42 | {
43 | "cell_type": "markdown",
44 | "source": [
45 | "## What is Python?\n",
46 | "Python is a popular programming language. It was created by Guido van Rossum, and released in 1991.\n",
47 | "\n",
48 | "It is used for:\n",
49 | "\n",
50 | "* web development (server-side),\n",
51 | "* software development,\n",
52 | "* mathematics, system scripting."
53 | ],
54 | "metadata": {
55 | "id": "ivoWzPIyqi09"
56 | }
57 | },
58 | {
59 | "cell_type": "markdown",
60 | "source": [
61 | "## What can Python do?\n",
62 | "* Python can be used on a server to create web applications.\n",
63 | "* Python can be used alongside software to create workflows.\n",
64 | "* Python can connect to database systems. It can also read and modify files.\n",
65 | "* Python can be used to handle big data and perform complex mathematics.\n",
66 | "* Python can be used for rapid prototyping, or for production-ready software development."
67 | ],
68 | "metadata": {
69 | "id": "AhJXftQaqw6W"
70 | }
71 | },
72 | {
73 | "cell_type": "markdown",
74 | "source": [
75 | "## Why Python?\n",
76 | "* Python works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc).\n",
77 | "* Python has a simple syntax similar to the English language.\n",
78 | "* Python has syntax that allows developers to write programs with fewer lines than some other programming languages.\n",
79 | "* Python runs on an interpreter system, meaning that code can be executed as soon as it is written. This means that prototyping can be very quick.\n",
80 | "* Python can be treated in a procedural way, an object-oriented way or a functional way."
81 | ],
82 | "metadata": {
83 | "id": "x7f9wBzeq56Y"
84 | }
85 | },
86 | {
87 | "cell_type": "markdown",
88 | "source": [
89 | "##Python Indentation\n",
90 | "* Indentation refers to the spaces at the beginning of a code line.\n",
91 | "\n",
92 | "* Where in other programming languages the indentation in code is for readability only, the indentation in Python is very important.\n",
93 | "\n",
94 | "Python uses indentation to indicate a block of code."
95 | ],
96 | "metadata": {
97 | "id": "3C3SxhI3rckv"
98 | }
99 | },
100 | {
101 | "cell_type": "markdown",
102 | "source": [
103 | "##First Program"
104 | ],
105 | "metadata": {
106 | "id": "JYtuLuS44Lbw"
107 | }
108 | },
109 | {
110 | "cell_type": "code",
111 | "source": [
112 | "print(\"Hello World\")"
113 | ],
114 | "metadata": {
115 | "colab": {
116 | "base_uri": "https://localhost:8080/"
117 | },
118 | "id": "miPLTFmd4ZPd",
119 | "outputId": "f2de0c87-7ff3-4589-d207-a1218a58d758"
120 | },
121 | "execution_count": null,
122 | "outputs": [
123 | {
124 | "output_type": "stream",
125 | "name": "stdout",
126 | "text": [
127 | "Hello World\n"
128 | ]
129 | }
130 | ]
131 | },
132 | {
133 | "cell_type": "markdown",
134 | "source": [
135 | "#Day-2"
136 | ],
137 | "metadata": {
138 | "id": "VcgY2PG9v06K"
139 | }
140 | },
141 | {
142 | "cell_type": "markdown",
143 | "source": [
144 | "## Python Comments\n",
145 | "### Comments Uses\n",
146 | "\n",
147 | "* Comments can be used to explain Python code.\n",
148 | "* Comments can be used to make the code more readable.\n",
149 | "* Comments can be used to prevent execution when testing code.\n",
150 | "\n"
151 | ],
152 | "metadata": {
153 | "id": "2-vyAn3N-Uuz"
154 | }
155 | },
156 | {
157 | "cell_type": "markdown",
158 | "source": [
159 | "\n",
160 | "### Type of Comments in Python\n",
161 | "\n",
162 | "1. Single line comment\n",
163 | "2. Multi line comment"
164 | ],
165 | "metadata": {
166 | "id": "sOYB4PbSwneQ"
167 | }
168 | },
169 | {
170 | "cell_type": "code",
171 | "source": [
172 | "#This is Single Line Comment\n",
173 | "print(\"Single Comment\")\n",
174 | "\n",
175 | "\"\"\"\n",
176 | "This is Mutli Line Comment\n",
177 | "\"\"\"\n",
178 | "\n",
179 | "'''\n",
180 | "This is Also Multi Line Comment\n",
181 | "\n",
182 | "'''"
183 | ],
184 | "metadata": {
185 | "colab": {
186 | "base_uri": "https://localhost:8080/",
187 | "height": 53
188 | },
189 | "id": "8EPGHfl3_DUA",
190 | "outputId": "5c7b5da9-e1d8-4b5c-f8e6-4455de6575ba"
191 | },
192 | "execution_count": null,
193 | "outputs": [
194 | {
195 | "output_type": "stream",
196 | "name": "stdout",
197 | "text": [
198 | "Single Comment\n"
199 | ]
200 | },
201 | {
202 | "output_type": "execute_result",
203 | "data": {
204 | "text/plain": [
205 | "'\\nThis is Also Multi Line Comment\\n\\n'"
206 | ],
207 | "application/vnd.google.colaboratory.intrinsic+json": {
208 | "type": "string"
209 | }
210 | },
211 | "metadata": {},
212 | "execution_count": 6
213 | }
214 | ]
215 | },
216 | {
217 | "cell_type": "markdown",
218 | "source": [
219 | "## Variables\n",
220 | "\n",
221 | "\n",
222 | "A variable should be named according to following rules:\n",
223 | "\n",
224 | "1. A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ ).\n",
225 | "2. A variable name must start with a letter or the underscore character.\n",
226 | "3. Variable names are case sensitive.\n",
227 | "4.Variable name shouldn't be any keyword of Python."
228 | ],
229 | "metadata": {
230 | "id": "Xsopy107_rm3"
231 | }
232 | },
233 | {
234 | "cell_type": "markdown",
235 | "source": [
236 | "### Naming a Multi words Varaible\n",
237 | "* Variable names with more than one word can be difficult to read.\n",
238 | "\n",
239 | "* There are several techniques you can use to make them more readable:\n",
240 | "\n",
241 | "3 methods to name a variable:\n",
242 | "\n",
243 | "1. Camel Case\n",
244 | "\n",
245 | "2. Pascal Case\n",
246 | "\n",
247 | "3. Snake Case"
248 | ],
249 | "metadata": {
250 | "id": "_w79yNYKAlvh"
251 | }
252 | },
253 | {
254 | "cell_type": "markdown",
255 | "source": [
256 | "####Camel Case\n",
257 | "* When using camel case, you start by making the first word lowercase. Then, you capitalize the first letter of each word that follows.\n",
258 | "\n",
259 | "* So, a capital letter appears at the start of the second word and at each new subsequent word that follows it.\n",
260 | "* Each word, except the first, starts with a capital letter:"
261 | ],
262 | "metadata": {
263 | "id": "BV9pUpzzzkBc"
264 | }
265 | },
266 | {
267 | "cell_type": "code",
268 | "source": [
269 | "#Camel Case Variable\n",
270 | "classThreeStudents=45\n",
271 | "bigThree=\"India\",\"Austrilia\",\"England\"\n",
272 | "print(classThreeStudents)\n"
273 | ],
274 | "metadata": {
275 | "colab": {
276 | "base_uri": "https://localhost:8080/"
277 | },
278 | "id": "HreU7lM8AxA1",
279 | "outputId": "65278511-c552-4ea3-9d46-8a6364814a98"
280 | },
281 | "execution_count": null,
282 | "outputs": [
283 | {
284 | "output_type": "stream",
285 | "name": "stdout",
286 | "text": [
287 | "45\n"
288 | ]
289 | }
290 | ]
291 | },
292 | {
293 | "cell_type": "markdown",
294 | "source": [
295 | "####Pascal Case\n",
296 | "* Pascal case is similar to camel case.\n",
297 | "* Each word starts with a capital letter:\n",
298 | "* The only difference between the two is that pascal case requires the first letter of the first word to also be capitalized.\n",
299 | "\n",
300 | "* So, when using pascal case, every word starts with an uppercase letter (in contrast to camel case, where the first word is in lowercase).\n"
301 | ],
302 | "metadata": {
303 | "id": "ADVSsaHS0S59"
304 | }
305 | },
306 | {
307 | "cell_type": "code",
308 | "source": [
309 | "#Pascal Case Variable\n",
310 | "Myname=\"Kousar Raza\"\n",
311 | "Yourname=\"ABC\"\n",
312 | "print(Myname)"
313 | ],
314 | "metadata": {
315 | "id": "E1D0k4JSBuOu"
316 | },
317 | "execution_count": null,
318 | "outputs": []
319 | },
320 | {
321 | "cell_type": "markdown",
322 | "source": [
323 | "#### Snake Case\n",
324 | "* Snake case is used for creating variable and method names.\n",
325 | "\n",
326 | "* Each word is separated by an underscore character\n",
327 | "* Snake case is also a good choice for naming files, as it keeps names readable.\n",
328 | "\n",
329 | "* You will typically encounter it the most when programming in Python and not so much when programming in Java, JavaScript, or TypeScript.\n",
330 | "\n",
331 | "* You will also come across it when working with databases, as it is used for creating table and column names.\n",
332 | "\n",
333 | "* There is also an all-caps version of the snake case where all letters are in the upper case - also known as the screaming snake case."
334 | ],
335 | "metadata": {
336 | "id": "aJpypLAz0-VC"
337 | }
338 | },
339 | {
340 | "cell_type": "code",
341 | "source": [
342 | "#Snake Case Variable\n",
343 | "#It means that we delimit words with an underscore.\n",
344 | "class_Three_Total_Students=45\n"
345 | ],
346 | "metadata": {
347 | "id": "NLcOmGpjCsgC"
348 | },
349 | "execution_count": null,
350 | "outputs": []
351 | },
352 | {
353 | "cell_type": "markdown",
354 | "source": [
355 | "### Many Values to Multiple Variables\n",
356 | "Python allows you to assign values to multiple variables in one line:"
357 | ],
358 | "metadata": {
359 | "id": "sAYjpv4s1vIF"
360 | }
361 | },
362 | {
363 | "cell_type": "code",
364 | "source": [
365 | "x,y ,z= \"Green\",\"Blue\",\"Black\"\n",
366 | "print(x,y,z)"
367 | ],
368 | "metadata": {
369 | "colab": {
370 | "base_uri": "https://localhost:8080/"
371 | },
372 | "id": "MKG34wQr13pP",
373 | "outputId": "baadada9-9e0d-4f04-8e03-59ef2af87f71"
374 | },
375 | "execution_count": null,
376 | "outputs": [
377 | {
378 | "output_type": "stream",
379 | "name": "stdout",
380 | "text": [
381 | "Green Blue Black\n"
382 | ]
383 | }
384 | ]
385 | },
386 | {
387 | "cell_type": "markdown",
388 | "source": [
389 | "### One Value to Multiple Variables\n",
390 | "* And you can assign the same value to multiple variables in one line"
391 | ],
392 | "metadata": {
393 | "id": "KkxiBLv72kUO"
394 | }
395 | },
396 | {
397 | "cell_type": "code",
398 | "source": [
399 | "x = y = z = \"Orange\"\n",
400 | "print(x)\n",
401 | "print(y)\n",
402 | "print(z)"
403 | ],
404 | "metadata": {
405 | "colab": {
406 | "base_uri": "https://localhost:8080/"
407 | },
408 | "id": "5g1lmigD2_s8",
409 | "outputId": "a516e1e9-c43b-4fd6-e31a-b85f9f33b3ef"
410 | },
411 | "execution_count": null,
412 | "outputs": [
413 | {
414 | "output_type": "stream",
415 | "name": "stdout",
416 | "text": [
417 | "Orange\n",
418 | "Orange\n",
419 | "Orange\n"
420 | ]
421 | }
422 | ]
423 | },
424 | {
425 | "cell_type": "markdown",
426 | "source": [
427 | "## Output Variables\n",
428 | "* The Python print() function is often used to output variables."
429 | ],
430 | "metadata": {
431 | "id": "aVWpCOjO3ZWi"
432 | }
433 | },
434 | {
435 | "cell_type": "code",
436 | "source": [
437 | "x = \"Python is awesome\"\n",
438 | "print(x)"
439 | ],
440 | "metadata": {
441 | "colab": {
442 | "base_uri": "https://localhost:8080/"
443 | },
444 | "id": "aAkfxRNM32br",
445 | "outputId": "232d937d-dea4-433e-9fae-7472a2eaed05"
446 | },
447 | "execution_count": null,
448 | "outputs": [
449 | {
450 | "output_type": "stream",
451 | "name": "stdout",
452 | "text": [
453 | "Python is awesome\n"
454 | ]
455 | }
456 | ]
457 | },
458 | {
459 | "cell_type": "markdown",
460 | "source": [
461 | "In the print() function, you output multiple variables, separated by a comma:"
462 | ],
463 | "metadata": {
464 | "id": "O4PC6nIu38sh"
465 | }
466 | },
467 | {
468 | "cell_type": "code",
469 | "source": [
470 | "x = \"Python\"\n",
471 | "y = \"is\"\n",
472 | "z = \"awesome\"\n",
473 | "print(x, y, z)"
474 | ],
475 | "metadata": {
476 | "colab": {
477 | "base_uri": "https://localhost:8080/"
478 | },
479 | "id": "gc8x8Yi54QMD",
480 | "outputId": "468245b0-93cf-43cc-bf77-429312e18b79"
481 | },
482 | "execution_count": null,
483 | "outputs": [
484 | {
485 | "output_type": "stream",
486 | "name": "stdout",
487 | "text": [
488 | "Python is awesome\n"
489 | ]
490 | }
491 | ]
492 | },
493 | {
494 | "cell_type": "markdown",
495 | "source": [
496 | "You can also use the + operator to output multiple variables:"
497 | ],
498 | "metadata": {
499 | "id": "iHHjfH7L4dSc"
500 | }
501 | },
502 | {
503 | "cell_type": "code",
504 | "source": [
505 | "x = \"Python \"\n",
506 | "y = \"is \"\n",
507 | "z = \"awesome\"\n",
508 | "print(x + y + z)"
509 | ],
510 | "metadata": {
511 | "colab": {
512 | "base_uri": "https://localhost:8080/"
513 | },
514 | "id": "EKsfWzWN4enA",
515 | "outputId": "21db9b03-19f0-42da-e030-ce092569a56e"
516 | },
517 | "execution_count": null,
518 | "outputs": [
519 | {
520 | "output_type": "stream",
521 | "name": "stdout",
522 | "text": [
523 | "Python is awesome\n"
524 | ]
525 | }
526 | ]
527 | },
528 | {
529 | "cell_type": "markdown",
530 | "source": [
531 | "###End and Sep\n",
532 | "* We can use End command in the end of print function.\n",
533 | "* Syntax is: print(1,2,3,End=\" .\")\n",
534 | "\n",
535 | "* Sep command used to seprated the values from print funcction\n",
536 | "* Syntax is : print(1,2,3,4,sep=\"-\")"
537 | ],
538 | "metadata": {
539 | "id": "Lm2UQOHRziij"
540 | }
541 | },
542 | {
543 | "cell_type": "code",
544 | "source": [
545 | "print(1,2,3,4, end=\".\\n\")\n",
546 | "\n",
547 | "print(1,2,3,4,5,sep=\"-\")"
548 | ],
549 | "metadata": {
550 | "id": "v3l7qB8S0xBR",
551 | "outputId": "f19b5da2-b20b-4121-dd28-57bbb34c3deb",
552 | "colab": {
553 | "base_uri": "https://localhost:8080/"
554 | }
555 | },
556 | "execution_count": null,
557 | "outputs": [
558 | {
559 | "output_type": "stream",
560 | "name": "stdout",
561 | "text": [
562 | "1 2 3 4.\n",
563 | "1-2-3-4-5\n"
564 | ]
565 | }
566 | ]
567 | },
568 | {
569 | "cell_type": "markdown",
570 | "source": [
571 | "#Day-3"
572 | ],
573 | "metadata": {
574 | "id": "Bs0mOGjL5J0O"
575 | }
576 | },
577 | {
578 | "cell_type": "markdown",
579 | "source": [
580 | "## Data Types\n",
581 | "\n",
582 | "* In programming, data type is an important concept.\n",
583 | "\n",
584 | "* Variables can store data of different types, and different types can do different things.\n",
585 | "\n",
586 | "Python has the following data types built-in by default, in these categories: \n",
587 | "\n",
588 | "1. Text Type:\tstr\n",
589 | "\n",
590 | "2. Numeric Types:\tint, float, complex\n",
591 | "3. Sequence Types:\tlist, tuple, range\n",
592 | "4. Mapping Type:\tdict\n",
593 | "5. Set Types:\tset, frozenset\n",
594 | "6. Boolean Type:\tbool\n",
595 | "7. Binary Types:\tbytes, bytearray, memoryview\n",
596 | "8. None Type:\tNoneType"
597 | ],
598 | "metadata": {
599 | "id": "C3vAKuYh5Nxp"
600 | }
601 | },
602 | {
603 | "cell_type": "markdown",
604 | "source": [
605 | "### Python Numbers\n",
606 | "There are three numeric types in Python:\n",
607 | "\n",
608 | "1. int\n",
609 | "2. float\n",
610 | "3. complex"
611 | ],
612 | "metadata": {
613 | "id": "U2_Xbvz16eTS"
614 | }
615 | },
616 | {
617 | "cell_type": "code",
618 | "source": [
619 | "x=24 #int data type\n",
620 | "y=2.5 #float data type\n",
621 | "z= 1j # copmlex data type\n",
622 | "print(x,y,z)"
623 | ],
624 | "metadata": {
625 | "colab": {
626 | "base_uri": "https://localhost:8080/"
627 | },
628 | "id": "E-NCpcOB6kGN",
629 | "outputId": "7e488724-3585-4ead-fc0b-7b863814337d"
630 | },
631 | "execution_count": null,
632 | "outputs": [
633 | {
634 | "output_type": "stream",
635 | "name": "stdout",
636 | "text": [
637 | "24 2.5 1j\n"
638 | ]
639 | }
640 | ]
641 | },
642 | {
643 | "cell_type": "markdown",
644 | "source": [
645 | "####Int\n",
646 | "* Int, or integer, is a whole number, positive or negative, without decimals, of unlimited length."
647 | ],
648 | "metadata": {
649 | "id": "e6aw090b71dc"
650 | }
651 | },
652 | {
653 | "cell_type": "code",
654 | "source": [
655 | "x = 1\n",
656 | "y = 35656222554887711\n",
657 | "z = -3255522\n",
658 | "\n",
659 | "print(type(x))\n",
660 | "print(type(y))\n",
661 | "print(type(z))"
662 | ],
663 | "metadata": {
664 | "colab": {
665 | "base_uri": "https://localhost:8080/"
666 | },
667 | "id": "yvyOsK1e8AIo",
668 | "outputId": "9c981062-d14d-4e2a-f9ec-142d7f63c7d5"
669 | },
670 | "execution_count": null,
671 | "outputs": [
672 | {
673 | "output_type": "stream",
674 | "name": "stdout",
675 | "text": [
676 | "\n",
677 | "\n",
678 | "\n"
679 | ]
680 | }
681 | ]
682 | },
683 | {
684 | "cell_type": "markdown",
685 | "source": [
686 | "####Float\n",
687 | "* Float, or \"floating point number\" is a number, positive or negative, containing one or more decimals."
688 | ],
689 | "metadata": {
690 | "id": "gI2430yE8Pz7"
691 | }
692 | },
693 | {
694 | "cell_type": "code",
695 | "source": [
696 | "x = 1.10\n",
697 | "y = 1.0\n",
698 | "z = -35.59"
699 | ],
700 | "metadata": {
701 | "id": "c4o6223U8bu1"
702 | },
703 | "execution_count": null,
704 | "outputs": []
705 | },
706 | {
707 | "cell_type": "markdown",
708 | "source": [
709 | "Float can also be scientific numbers with an \"e\" to indicate the power of 10."
710 | ],
711 | "metadata": {
712 | "id": "cGvxU4py8l--"
713 | }
714 | },
715 | {
716 | "cell_type": "code",
717 | "source": [
718 | "x = 35e3\n",
719 | "y = 12E4\n",
720 | "z = -87.7e100\n",
721 | "\n",
722 | "print(type(x))\n",
723 | "print(type(y))\n",
724 | "print(type(z))"
725 | ],
726 | "metadata": {
727 | "colab": {
728 | "base_uri": "https://localhost:8080/"
729 | },
730 | "id": "qUxTSPJ_8oMX",
731 | "outputId": "811d5573-7daa-4571-f24a-e3368feae57c"
732 | },
733 | "execution_count": null,
734 | "outputs": [
735 | {
736 | "output_type": "stream",
737 | "name": "stdout",
738 | "text": [
739 | "\n",
740 | "\n",
741 | "\n"
742 | ]
743 | }
744 | ]
745 | },
746 | {
747 | "cell_type": "markdown",
748 | "source": [
749 | "####Complex\n",
750 | "* Complex numbers are written with a \"j\" as the imaginary part: "
751 | ],
752 | "metadata": {
753 | "id": "fzXFD96t8vej"
754 | }
755 | },
756 | {
757 | "cell_type": "code",
758 | "source": [
759 | "x = 3+5j\n",
760 | "y = 5j\n",
761 | "z = -5j\n",
762 | "\n",
763 | "print(type(x))\n",
764 | "print(type(y))\n",
765 | "print(type(z))"
766 | ],
767 | "metadata": {
768 | "colab": {
769 | "base_uri": "https://localhost:8080/"
770 | },
771 | "id": "2nHTBl5Z9IqX",
772 | "outputId": "308e35de-99b7-4564-fe97-af813f7cfcc6"
773 | },
774 | "execution_count": null,
775 | "outputs": [
776 | {
777 | "output_type": "stream",
778 | "name": "stdout",
779 | "text": [
780 | "\n",
781 | "\n",
782 | "\n"
783 | ]
784 | }
785 | ]
786 | },
787 | {
788 | "cell_type": "markdown",
789 | "source": [
790 | "###Check Type of Data\n",
791 | "type() method used to check the type of data"
792 | ],
793 | "metadata": {
794 | "id": "sd6pAI1t6-e3"
795 | }
796 | },
797 | {
798 | "cell_type": "code",
799 | "source": [
800 | "print(type(x))\n",
801 | "print(type(y))\n",
802 | "print(type(z))"
803 | ],
804 | "metadata": {
805 | "colab": {
806 | "base_uri": "https://localhost:8080/"
807 | },
808 | "id": "AiYjDtt27Cqr",
809 | "outputId": "ca37b0d9-4701-485b-af24-65d3d02b2ffb"
810 | },
811 | "execution_count": null,
812 | "outputs": [
813 | {
814 | "output_type": "stream",
815 | "name": "stdout",
816 | "text": [
817 | "\n",
818 | "\n",
819 | "\n"
820 | ]
821 | }
822 | ]
823 | },
824 | {
825 | "cell_type": "markdown",
826 | "source": [
827 | "###String\n",
828 | "* String is a sequence of characters uncloased in quotes.\n",
829 | "* Strings in python are surrounded by either single quotation marks, or double quotation marks or triple quotation marks .\n",
830 | "\n",
831 | "* 'hello' is the same as \"hello\" and \"\"\"hello\"\"\".\n",
832 | "\n",
833 | "\n",
834 | "* You can display a string literal with the print() function:"
835 | ],
836 | "metadata": {
837 | "id": "oLRsQLj1_4bn"
838 | }
839 | },
840 | {
841 | "cell_type": "code",
842 | "source": [
843 | "a='hello world '\n",
844 | "b=\"hello world\"\n",
845 | "c=\"\"\"hello world\"\"\"\n",
846 | "\n",
847 | "print(a)\n",
848 | "print(b)\n",
849 | "print(c)"
850 | ],
851 | "metadata": {
852 | "id": "8XIV2wzOBEfi",
853 | "outputId": "e03043f6-93e4-4779-cbd7-7bf64c743f90",
854 | "colab": {
855 | "base_uri": "https://localhost:8080/"
856 | }
857 | },
858 | "execution_count": null,
859 | "outputs": [
860 | {
861 | "output_type": "stream",
862 | "name": "stdout",
863 | "text": [
864 | "hello world \n",
865 | "hello world\n",
866 | "hello world\n"
867 | ]
868 | }
869 | ]
870 | },
871 | {
872 | "cell_type": "markdown",
873 | "source": [
874 | "####Acces the element from String(Slicing)\n",
875 | "\n",
876 | "* You can return a range of characters by using the slice syntax.\n",
877 | "\n",
878 | "* Specify the start index and the end index, separated by a colon, to return a part of the string.\n"
879 | ],
880 | "metadata": {
881 | "id": "fttjL6a52vRc"
882 | }
883 | },
884 | {
885 | "cell_type": "markdown",
886 | "source": [
887 | "Get the characters from position 2 to position 5 (not included):"
888 | ],
889 | "metadata": {
890 | "id": "NrdqrCOs3bY3"
891 | }
892 | },
893 | {
894 | "cell_type": "code",
895 | "source": [
896 | "print(a[2:5])"
897 | ],
898 | "metadata": {
899 | "id": "aGxPNZUl3KG_",
900 | "outputId": "f5da32a5-85d7-445e-ac5a-238e1991b5a4",
901 | "colab": {
902 | "base_uri": "https://localhost:8080/"
903 | }
904 | },
905 | "execution_count": null,
906 | "outputs": [
907 | {
908 | "output_type": "stream",
909 | "name": "stdout",
910 | "text": [
911 | "llo\n"
912 | ]
913 | }
914 | ]
915 | },
916 | {
917 | "cell_type": "markdown",
918 | "source": [
919 | "Note:\n",
920 | "The first character has index 0.\n",
921 | "\n"
922 | ],
923 | "metadata": {
924 | "id": "K7-pVR0n3dhW"
925 | }
926 | },
927 | {
928 | "cell_type": "markdown",
929 | "source": [
930 | "#####Slice From the Start\n",
931 | "* By leaving out the start index, the range will start at the first character:\n",
932 | "\n",
933 | "* Example : Get the characters from the start to position 5 (not included):"
934 | ],
935 | "metadata": {
936 | "id": "nkdiMxkb3pUW"
937 | }
938 | },
939 | {
940 | "cell_type": "code",
941 | "source": [
942 | "print(b[:5])"
943 | ],
944 | "metadata": {
945 | "id": "-yhPqazZ3z0y",
946 | "outputId": "3d099d0b-7db1-452b-9e47-4fb4fd1baed2",
947 | "colab": {
948 | "base_uri": "https://localhost:8080/"
949 | }
950 | },
951 | "execution_count": null,
952 | "outputs": [
953 | {
954 | "output_type": "stream",
955 | "name": "stdout",
956 | "text": [
957 | "hello\n"
958 | ]
959 | }
960 | ]
961 | },
962 | {
963 | "cell_type": "markdown",
964 | "source": [
965 | "##### Slice To the End\n",
966 | "* By leaving out the end index, the range will go to the end:\n",
967 | "\n",
968 | "* Example: Get the characters from position 2, and all the way to the end:\n"
969 | ],
970 | "metadata": {
971 | "id": "qhidD_wS4Adh"
972 | }
973 | },
974 | {
975 | "cell_type": "code",
976 | "source": [
977 | "print(c[1:])"
978 | ],
979 | "metadata": {
980 | "id": "oNvO7zMj4KZG",
981 | "outputId": "9e99d65a-ceab-4551-9a72-10e08770f6c5",
982 | "colab": {
983 | "base_uri": "https://localhost:8080/"
984 | }
985 | },
986 | "execution_count": null,
987 | "outputs": [
988 | {
989 | "output_type": "stream",
990 | "name": "stdout",
991 | "text": [
992 | "el ol\n"
993 | ]
994 | }
995 | ]
996 | },
997 | {
998 | "cell_type": "markdown",
999 | "source": [
1000 | "#### Negative Indexing\n",
1001 | "* Use negative indexes to start the slice from the end of the string:\n",
1002 | "* Example\n",
1003 | "Get the characters:\n",
1004 | "\n",
1005 | "From: \"o\" in \"World!\" (position -5)\n",
1006 | "\n",
1007 | "To, but not included: \"d\" in \"World!\" (position -2):"
1008 | ],
1009 | "metadata": {
1010 | "id": "FZqTPg0h4pt6"
1011 | }
1012 | },
1013 | {
1014 | "cell_type": "code",
1015 | "source": [
1016 | "b = \"Hello, World!\"\n",
1017 | "print(b[-5:-2])"
1018 | ],
1019 | "metadata": {
1020 | "id": "eZKAsTNu46GM",
1021 | "outputId": "bdff6477-e369-4e07-9454-9ce2896d971d",
1022 | "colab": {
1023 | "base_uri": "https://localhost:8080/"
1024 | }
1025 | },
1026 | "execution_count": null,
1027 | "outputs": [
1028 | {
1029 | "output_type": "stream",
1030 | "name": "stdout",
1031 | "text": [
1032 | "orl\n"
1033 | ]
1034 | }
1035 | ]
1036 | },
1037 | {
1038 | "cell_type": "markdown",
1039 | "source": [
1040 | "####String Methods\n",
1041 | "* Python has a set of built-in methods that you can use on strings.\n",
1042 | "\n",
1043 | "* Note: All string methods returns new values. They do not change the original string.\n",
1044 | "\n",
1045 | "* Some of the most comman functions to perform operations on or manipulate strings are:\n",
1046 | "\n",
1047 | "1. len()\n",
1048 | "2. string.count()\n",
1049 | "3. string.capitalize()\n",
1050 | "4. string.find(word)\n",
1051 | "5. string.replace(oldtext, newtext)\n",
1052 | "6. string.lower()\n",
1053 | "7. string.upper()\n",
1054 | "8. string.center()\n",
1055 | "\n"
1056 | ],
1057 | "metadata": {
1058 | "id": "ppbpAXhl5lfH"
1059 | }
1060 | },
1061 | {
1062 | "cell_type": "code",
1063 | "source": [
1064 | "a=\"hello World This is Kousar raza\"\n",
1065 | "\n",
1066 | "#find len\n",
1067 | "print(len(a))\n",
1068 | "\n",
1069 | "#count 0 from a\n",
1070 | "print(a.count('o'))\n",
1071 | "\n",
1072 | "#capitalize\n",
1073 | "print(a.capitalize())\n",
1074 | "\n",
1075 | "#find string from a\n",
1076 | "\n",
1077 | "print(a.find(\"raza\"))\n",
1078 | "\n",
1079 | "#replace\n",
1080 | "\n",
1081 | "print(a.replace(\"This is Kousar raza\",\"Kousar Raza\"))"
1082 | ],
1083 | "metadata": {
1084 | "colab": {
1085 | "base_uri": "https://localhost:8080/"
1086 | },
1087 | "id": "mo-fUDZqgQL9",
1088 | "outputId": "14afa820-3766-412b-89af-99787c4a17a6"
1089 | },
1090 | "execution_count": 5,
1091 | "outputs": [
1092 | {
1093 | "output_type": "stream",
1094 | "name": "stdout",
1095 | "text": [
1096 | "32\n",
1097 | "3\n",
1098 | "Hello world this is kousar raza\n",
1099 | "28\n",
1100 | "hello World This is Kousar raza\n"
1101 | ]
1102 | }
1103 | ]
1104 | }
1105 | ]
1106 | }
--------------------------------------------------------------------------------
/DataType and Variables:
--------------------------------------------------------------------------------
1 |
2 | #Integer data type
3 | """ a=7
4 | b=3.5
5 | print(a)
6 | print(b)
7 | """
8 |
9 | #String
10 | """ a="Apple"
11 | b="Banana"
12 | x,y="Kiwi","Mango"
13 | print(a)
14 | print(b)
15 | print(x+"\n"+y) """
16 |
17 | #Float data type
18 |
19 | """ x=12.4
20 | y=34.6
21 | print(x+y) """
22 |
23 |
24 | #Complex Data Type
25 | """ x=23j
26 | y=26j
27 | print(x+y) """
28 |
29 |
30 | #Type Conversion one data type to another data type
31 | # String to Int
32 |
33 | a=3
34 | b='3'
35 |
36 | #now we add 3 and 3, note value of b is string, first we change it into int then add.
37 | print(a+int(b))
38 |
39 | #Int to String
40 | x=33
41 | y='kousar'
42 | print(str(x)+y)
43 |
44 |
45 | #Float to Int and Int to Float
46 | n1=3.3
47 | n2=4
48 | print(int(n1))
49 | print(float(n2))
50 |
51 | #Check Data type
52 | print(type(n1))
53 | print(type(n2))
54 |
55 |
56 | #Random Function in Python
57 | import random
58 | print(random.randrange(1,10)) #It Generate random number between 1 and 10 on every time run.
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/Day_1(Introduction_to_Python).ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "nbformat": 4,
3 | "nbformat_minor": 0,
4 | "metadata": {
5 | "colab": {
6 | "provenance": [],
7 | "authorship_tag": "ABX9TyM4UhcvipkG/Ou4fSRaOHB5",
8 | "include_colab_link": true
9 | },
10 | "kernelspec": {
11 | "name": "python3",
12 | "display_name": "Python 3"
13 | },
14 | "language_info": {
15 | "name": "python"
16 | }
17 | },
18 | "cells": [
19 | {
20 | "cell_type": "markdown",
21 | "metadata": {
22 | "id": "view-in-github",
23 | "colab_type": "text"
24 | },
25 | "source": [
26 | "
"
27 | ]
28 | },
29 | {
30 | "cell_type": "markdown",
31 | "source": [
32 | "#Day_1\n"
33 | ],
34 | "metadata": {
35 | "id": "uxI5f_L2LWIe"
36 | }
37 | },
38 | {
39 | "cell_type": "markdown",
40 | "source": [
41 | "## What is Python?\n",
42 | "Python is a popular programming language. It was created by Guido van Rossum, and released in 1991.\n",
43 | "\n",
44 | "It is used for:\n",
45 | "\n",
46 | "* web development (server-side),\n",
47 | "* software development,\n",
48 | "* mathematics, system scripting."
49 | ],
50 | "metadata": {
51 | "id": "_J0Tb7f6Lg29"
52 | }
53 | },
54 | {
55 | "cell_type": "markdown",
56 | "source": [
57 | "## What can Python do?\n",
58 | "* Python can be used on a server to create web applications.\n",
59 | "* Python can be used alongside software to create workflows.\n",
60 | "* Python can connect to database systems. It can also read and modify files.\n",
61 | "* Python can be used to handle big data and perform complex mathematics.\n",
62 | "* Python can be used for rapid prototyping, or for production-ready software development."
63 | ],
64 | "metadata": {
65 | "id": "tntvyiHNL4rg"
66 | }
67 | },
68 | {
69 | "cell_type": "markdown",
70 | "source": [
71 | "## Why Python?\n",
72 | "* Python works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc).\n",
73 | "* Python has a simple syntax similar to the English language.\n",
74 | "* Python has syntax that allows developers to write programs with fewer lines than some other programming languages.\n",
75 | "* Python runs on an interpreter system, meaning that code can be executed as soon as it is written. This means that prototyping can be very quick.\n",
76 | "* Python can be treated in a procedural way, an object-oriented way or a functional way."
77 | ],
78 | "metadata": {
79 | "id": "To4giYYfMFkv"
80 | }
81 | },
82 | {
83 | "cell_type": "markdown",
84 | "source": [
85 | "## Python Indentation\n",
86 | "* Indentation refers to the spaces at the beginning of a code line.\n",
87 | "\n",
88 | "* Where in other programming languages the indentation in code is for readability only, the indentation in Python is very important.\n",
89 | "\n",
90 | "Python uses indentation to indicate a block of code."
91 | ],
92 | "metadata": {
93 | "id": "L1ZcTiSTMSGC"
94 | }
95 | },
96 | {
97 | "cell_type": "markdown",
98 | "source": [
99 | "##First Program"
100 | ],
101 | "metadata": {
102 | "id": "xre0gDDOMcKt"
103 | }
104 | },
105 | {
106 | "cell_type": "code",
107 | "execution_count": null,
108 | "metadata": {
109 | "colab": {
110 | "base_uri": "https://localhost:8080/"
111 | },
112 | "id": "s_Wq399jKjPN",
113 | "outputId": "8a356c01-a0ea-494d-d54d-51509a7c6ef4"
114 | },
115 | "outputs": [
116 | {
117 | "output_type": "stream",
118 | "name": "stdout",
119 | "text": [
120 | "Hello World\n"
121 | ]
122 | }
123 | ],
124 | "source": [
125 | "print(\"Hello World\")"
126 | ]
127 | }
128 | ]
129 | }
--------------------------------------------------------------------------------
/Day_1.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "nbformat": 4,
3 | "nbformat_minor": 0,
4 | "metadata": {
5 | "colab": {
6 | "provenance": [],
7 | "authorship_tag": "ABX9TyM4UhcvipkG/Ou4fSRaOHB5",
8 | "include_colab_link": true
9 | },
10 | "kernelspec": {
11 | "name": "python3",
12 | "display_name": "Python 3"
13 | },
14 | "language_info": {
15 | "name": "python"
16 | }
17 | },
18 | "cells": [
19 | {
20 | "cell_type": "markdown",
21 | "metadata": {
22 | "id": "view-in-github",
23 | "colab_type": "text"
24 | },
25 | "source": [
26 | "
"
27 | ]
28 | },
29 | {
30 | "cell_type": "markdown",
31 | "source": [
32 | "#Day_1\n"
33 | ],
34 | "metadata": {
35 | "id": "uxI5f_L2LWIe"
36 | }
37 | },
38 | {
39 | "cell_type": "markdown",
40 | "source": [
41 | "## What is Python?\n",
42 | "Python is a popular programming language. It was created by Guido van Rossum, and released in 1991.\n",
43 | "\n",
44 | "It is used for:\n",
45 | "\n",
46 | "* web development (server-side),\n",
47 | "* software development,\n",
48 | "* mathematics, system scripting."
49 | ],
50 | "metadata": {
51 | "id": "_J0Tb7f6Lg29"
52 | }
53 | },
54 | {
55 | "cell_type": "markdown",
56 | "source": [
57 | "## What can Python do?\n",
58 | "* Python can be used on a server to create web applications.\n",
59 | "* Python can be used alongside software to create workflows.\n",
60 | "* Python can connect to database systems. It can also read and modify files.\n",
61 | "* Python can be used to handle big data and perform complex mathematics.\n",
62 | "* Python can be used for rapid prototyping, or for production-ready software development."
63 | ],
64 | "metadata": {
65 | "id": "tntvyiHNL4rg"
66 | }
67 | },
68 | {
69 | "cell_type": "markdown",
70 | "source": [
71 | "## Why Python?\n",
72 | "* Python works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc).\n",
73 | "* Python has a simple syntax similar to the English language.\n",
74 | "* Python has syntax that allows developers to write programs with fewer lines than some other programming languages.\n",
75 | "* Python runs on an interpreter system, meaning that code can be executed as soon as it is written. This means that prototyping can be very quick.\n",
76 | "* Python can be treated in a procedural way, an object-oriented way or a functional way."
77 | ],
78 | "metadata": {
79 | "id": "To4giYYfMFkv"
80 | }
81 | },
82 | {
83 | "cell_type": "markdown",
84 | "source": [
85 | "## Python Indentation\n",
86 | "* Indentation refers to the spaces at the beginning of a code line.\n",
87 | "\n",
88 | "* Where in other programming languages the indentation in code is for readability only, the indentation in Python is very important.\n",
89 | "\n",
90 | "Python uses indentation to indicate a block of code."
91 | ],
92 | "metadata": {
93 | "id": "L1ZcTiSTMSGC"
94 | }
95 | },
96 | {
97 | "cell_type": "markdown",
98 | "source": [
99 | "##First Program"
100 | ],
101 | "metadata": {
102 | "id": "xre0gDDOMcKt"
103 | }
104 | },
105 | {
106 | "cell_type": "code",
107 | "execution_count": null,
108 | "metadata": {
109 | "colab": {
110 | "base_uri": "https://localhost:8080/"
111 | },
112 | "id": "s_Wq399jKjPN",
113 | "outputId": "8a356c01-a0ea-494d-d54d-51509a7c6ef4"
114 | },
115 | "outputs": [
116 | {
117 | "output_type": "stream",
118 | "name": "stdout",
119 | "text": [
120 | "Hello World\n"
121 | ]
122 | }
123 | ],
124 | "source": [
125 | "print(\"Hello World\")"
126 | ]
127 | }
128 | ]
129 | }
--------------------------------------------------------------------------------
/Day_2(Python_Comments_&_Keywords).ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "nbformat": 4,
3 | "nbformat_minor": 0,
4 | "metadata": {
5 | "colab": {
6 | "provenance": [],
7 | "toc_visible": true,
8 | "authorship_tag": "ABX9TyNwCHlLKMmIaXbHw1N1kOCR",
9 | "include_colab_link": true
10 | },
11 | "kernelspec": {
12 | "name": "python3",
13 | "display_name": "Python 3"
14 | },
15 | "language_info": {
16 | "name": "python"
17 | }
18 | },
19 | "cells": [
20 | {
21 | "cell_type": "markdown",
22 | "metadata": {
23 | "id": "view-in-github",
24 | "colab_type": "text"
25 | },
26 | "source": [
27 | "
"
28 | ]
29 | },
30 | {
31 | "cell_type": "markdown",
32 | "source": [
33 | "##Day_2"
34 | ],
35 | "metadata": {
36 | "id": "XvhPHGa-O1IR"
37 | }
38 | },
39 | {
40 | "cell_type": "markdown",
41 | "source": [
42 | "##Python Comments\n",
43 | "Comments Uses\n",
44 | "* Comments can be used to explain Python code.\n",
45 | "* Comments can be used to make the code more readable.\n",
46 | "* Comments can be used to prevent execution when testing code."
47 | ],
48 | "metadata": {
49 | "id": "PM-TpNzAO80v"
50 | }
51 | },
52 | {
53 | "cell_type": "markdown",
54 | "source": [
55 | "###Type of Comments in Python\n",
56 | "1. Single line comment\n",
57 | "2. Multi line comment"
58 | ],
59 | "metadata": {
60 | "id": "v9Mn_PyXPNDL"
61 | }
62 | },
63 | {
64 | "cell_type": "code",
65 | "source": [
66 | "#This is Single Line Comment\n",
67 | "print(\"Single Line Comment\")\n",
68 | "\n",
69 | "\"\"\"This is Multi line comment\n",
70 | "Hello My name is Kousar Raza\"\"\"\n",
71 | "\n",
72 | "\n",
73 | "'''This is also a multi line comment'''\n"
74 | ],
75 | "metadata": {
76 | "id": "tha0_TlqPUF6"
77 | },
78 | "execution_count": null,
79 | "outputs": []
80 | },
81 | {
82 | "cell_type": "markdown",
83 | "source": [
84 | "##Reserved or Keywords in Pythons\n",
85 | "\n",
86 | "\n",
87 | "* Keywords are predefined, reserved words used in Python programming that have special meanings to the interpreter.\n",
88 | "\n",
89 | "* We cannot use a keyword as a variable name, function name, or any other identifier. They are used to define the syntax and structure of the Python language.\n",
90 | "\n",
91 | "Following are some keywords in Python:\n",
92 | "\n",
93 | "##False, is, in, Lambda, True, None, if, elif, break, else, continue, class, not, and, or"
94 | ],
95 | "metadata": {
96 | "id": "0j9FUyMcePPO"
97 | }
98 | },
99 | {
100 | "cell_type": "code",
101 | "source": [
102 | "a = \"a variable\"\n",
103 | "is = \"won't allow a variable\"\n",
104 | "print(a)\n",
105 | "print(is)"
106 | ],
107 | "metadata": {
108 | "id": "NrkzwoRueun9",
109 | "outputId": "4d897a45-8efe-4382-f0b6-75456c39d2b4",
110 | "colab": {
111 | "base_uri": "https://localhost:8080/",
112 | "height": 140
113 | }
114 | },
115 | "execution_count": null,
116 | "outputs": [
117 | {
118 | "output_type": "error",
119 | "ename": "SyntaxError",
120 | "evalue": "ignored",
121 | "traceback": [
122 | "\u001b[0;36m File \u001b[0;32m\"\"\u001b[0;36m, line \u001b[0;32m2\u001b[0m\n\u001b[0;31m is = \"won't allow a variable\"\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m invalid syntax\n"
123 | ]
124 | }
125 | ]
126 | }
127 | ]
128 | }
--------------------------------------------------------------------------------
/Day_2.ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "nbformat": 4,
3 | "nbformat_minor": 0,
4 | "metadata": {
5 | "colab": {
6 | "provenance": [],
7 | "authorship_tag": "ABX9TyMFsZtX6T3s+q86e7SU3rOM",
8 | "include_colab_link": true
9 | },
10 | "kernelspec": {
11 | "name": "python3",
12 | "display_name": "Python 3"
13 | },
14 | "language_info": {
15 | "name": "python"
16 | }
17 | },
18 | "cells": [
19 | {
20 | "cell_type": "markdown",
21 | "metadata": {
22 | "id": "view-in-github",
23 | "colab_type": "text"
24 | },
25 | "source": [
26 | "
"
27 | ]
28 | },
29 | {
30 | "cell_type": "markdown",
31 | "source": [
32 | "##Day_2"
33 | ],
34 | "metadata": {
35 | "id": "XvhPHGa-O1IR"
36 | }
37 | },
38 | {
39 | "cell_type": "markdown",
40 | "source": [
41 | "##Python Comments\n",
42 | "Comments Uses\n",
43 | "* Comments can be used to explain Python code.\n",
44 | "* Comments can be used to make the code more readable.\n",
45 | "* Comments can be used to prevent execution when testing code."
46 | ],
47 | "metadata": {
48 | "id": "PM-TpNzAO80v"
49 | }
50 | },
51 | {
52 | "cell_type": "markdown",
53 | "source": [
54 | "## ype of Comments in Python\n",
55 | "1. Single line comment\n",
56 | "2. Multi line comment"
57 | ],
58 | "metadata": {
59 | "id": "v9Mn_PyXPNDL"
60 | }
61 | },
62 | {
63 | "cell_type": "code",
64 | "source": [
65 | "#This is Single Line Comment\n",
66 | "print(\"Single Line Comment\")\n",
67 | "\n",
68 | "\"\"\"This is Multi line comment\n",
69 | "Hello My name is Kousar Raza\"\"\"\n",
70 | "\n",
71 | "\n",
72 | "'''This is also"
73 | ],
74 | "metadata": {
75 | "id": "tha0_TlqPUF6"
76 | },
77 | "execution_count": null,
78 | "outputs": []
79 | },
80 | {
81 | "cell_type": "code",
82 | "execution_count": null,
83 | "metadata": {
84 | "id": "HUDD--obOyYa"
85 | },
86 | "outputs": [],
87 | "source": []
88 | }
89 | ]
90 | }
--------------------------------------------------------------------------------
/Day_3_(Python_Variables).ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "nbformat": 4,
3 | "nbformat_minor": 0,
4 | "metadata": {
5 | "colab": {
6 | "provenance": [],
7 | "toc_visible": true,
8 | "authorship_tag": "ABX9TyPTtpdhLvaYG73AQyUHR/EI",
9 | "include_colab_link": true
10 | },
11 | "kernelspec": {
12 | "name": "python3",
13 | "display_name": "Python 3"
14 | },
15 | "language_info": {
16 | "name": "python"
17 | }
18 | },
19 | "cells": [
20 | {
21 | "cell_type": "markdown",
22 | "metadata": {
23 | "id": "view-in-github",
24 | "colab_type": "text"
25 | },
26 | "source": [
27 | "
"
28 | ]
29 | },
30 | {
31 | "cell_type": "markdown",
32 | "source": [
33 | "#Day_3"
34 | ],
35 | "metadata": {
36 | "id": "KhZEZsQCmvaa"
37 | }
38 | },
39 | {
40 | "cell_type": "markdown",
41 | "source": [
42 | "##Variables\n",
43 | "A variable should be named according to following rules:\n",
44 | "\n",
45 | "* A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ ).\n",
46 | "* A variable name must start with a letter or the underscore character.\n",
47 | "* Variable names are case sensitive.\n",
48 | "* Variable name shouldn't be any keyword of Python.\n",
49 | "* Variable names are case-sensitive (age, Age and AGE are three different variables)"
50 | ],
51 | "metadata": {
52 | "id": "m05kNCfof7kC"
53 | }
54 | },
55 | {
56 | "cell_type": "code",
57 | "execution_count": null,
58 | "metadata": {
59 | "id": "c1q_OKrofmoO"
60 | },
61 | "outputs": [],
62 | "source": [
63 | " # ....correct method....\n",
64 | "_myVar5 = \"Cricket\"\n",
65 | "myVariableName = 95\n",
66 | "MyVariableName = 'Pakistan'\n",
67 | "myVariableName = 88.5\n",
68 | "print(myVariableName)\n"
69 | ]
70 | },
71 | {
72 | "cell_type": "code",
73 | "source": [
74 | "'''\n",
75 | " ...Wrong Method...\n",
76 | " _my Var = \"iCodeGuru\n",
77 | " 2myvariableName = 95\n",
78 | " &MyVariableName = 'Pakistan' --> (*&^%$#@!)not allowed at variable\n",
79 | "\n",
80 | " '''"
81 | ],
82 | "metadata": {
83 | "id": "mZebBEfdhALI"
84 | },
85 | "execution_count": null,
86 | "outputs": []
87 | },
88 | {
89 | "cell_type": "markdown",
90 | "source": [
91 | "###Types of variable name cases"
92 | ],
93 | "metadata": {
94 | "id": "Fx5XaQ1PhdIL"
95 | }
96 | },
97 | {
98 | "cell_type": "markdown",
99 | "source": [
100 | "####Camel Case Variable\n",
101 | "*Camel Case --> whose first word of variable is lower and second word is Upper case."
102 | ],
103 | "metadata": {
104 | "id": "TA61UTAQh3rn"
105 | }
106 | },
107 | {
108 | "cell_type": "code",
109 | "source": [
110 | "myName=\"Kousar Raza\"\n",
111 | "myAge=24\n",
112 | "\n",
113 | "print(myName)\n",
114 | "print(myAge)"
115 | ],
116 | "metadata": {
117 | "colab": {
118 | "base_uri": "https://localhost:8080/"
119 | },
120 | "id": "jbko_2j9hU9_",
121 | "outputId": "e27b5d3c-0c99-4179-f840-3bad5b20eda5"
122 | },
123 | "execution_count": 1,
124 | "outputs": [
125 | {
126 | "output_type": "stream",
127 | "name": "stdout",
128 | "text": [
129 | "Kousar Raza\n",
130 | "24\n"
131 | ]
132 | }
133 | ]
134 | },
135 | {
136 | "cell_type": "markdown",
137 | "source": [
138 | "#### Pascal Case Variable\n"
139 | ],
140 | "metadata": {
141 | "id": "K5bigY2aivP-"
142 | }
143 | },
144 | {
145 | "cell_type": "markdown",
146 | "source": [
147 | "* Who first and second letter words letter are upper case."
148 | ],
149 | "metadata": {
150 | "id": "TuO3us9Vi2lZ"
151 | }
152 | },
153 | {
154 | "cell_type": "code",
155 | "source": [
156 | "MyName=\"Kousar Raza\"\n",
157 | "MyAge=24\n",
158 | "print(MyName)\n",
159 | "print(MyAge)"
160 | ],
161 | "metadata": {
162 | "colab": {
163 | "base_uri": "https://localhost:8080/"
164 | },
165 | "id": "VtG-pmeajApF",
166 | "outputId": "64446e4d-da14-4727-bfc3-89970f3b94a0"
167 | },
168 | "execution_count": 3,
169 | "outputs": [
170 | {
171 | "output_type": "stream",
172 | "name": "stdout",
173 | "text": [
174 | "Kousar Raza\n",
175 | "24\n"
176 | ]
177 | }
178 | ]
179 | },
180 | {
181 | "cell_type": "markdown",
182 | "source": [
183 | "#### Snake Case Variable"
184 | ],
185 | "metadata": {
186 | "id": "btcLyjnFiSRY"
187 | }
188 | },
189 | {
190 | "cell_type": "markdown",
191 | "source": [
192 | "* Whose all letter are lower case.\n",
193 | "* Each word is separated by an underscore character\n"
194 | ],
195 | "metadata": {
196 | "id": "C9tpf6Bijea8"
197 | }
198 | },
199 | {
200 | "cell_type": "code",
201 | "source": [
202 | "my_name_=\"Pakistan\"\n",
203 | "my_country_code=92"
204 | ],
205 | "metadata": {
206 | "id": "RCqQyv2_iROP"
207 | },
208 | "execution_count": null,
209 | "outputs": []
210 | },
211 | {
212 | "cell_type": "markdown",
213 | "source": [
214 | "###Assigning values to the variable:\n",
215 | "* Assigning multiple values to multiple variables\n",
216 | "\n",
217 | "* Assigning one value to multiple variables"
218 | ],
219 | "metadata": {
220 | "id": "Kau3a199kC2p"
221 | }
222 | },
223 | {
224 | "cell_type": "markdown",
225 | "source": [
226 | "####Multiple Values to Multiple Variables\n",
227 | "Python allows you to assign values to multiple variables in one line."
228 | ],
229 | "metadata": {
230 | "id": "vfZ4zq5BkMaG"
231 | }
232 | },
233 | {
234 | "cell_type": "code",
235 | "source": [
236 | "x,y ,z= \"Green\",\"Blue\",\"Black\"\n",
237 | "print(x,y,z)"
238 | ],
239 | "metadata": {
240 | "colab": {
241 | "base_uri": "https://localhost:8080/"
242 | },
243 | "id": "_gsZx_RMkgn7",
244 | "outputId": "d44aca07-b712-493d-cd7e-86168a8dbdad"
245 | },
246 | "execution_count": 4,
247 | "outputs": [
248 | {
249 | "output_type": "stream",
250 | "name": "stdout",
251 | "text": [
252 | "Green Blue Black\n"
253 | ]
254 | }
255 | ]
256 | },
257 | {
258 | "cell_type": "markdown",
259 | "source": [
260 | "####One Value to Multiple Variables\n",
261 | "* And you can assign the same value to multiple variables in one line"
262 | ],
263 | "metadata": {
264 | "id": "sAi_eIxSknhD"
265 | }
266 | },
267 | {
268 | "cell_type": "code",
269 | "source": [
270 | "x = y = z = \"Orange\"\n",
271 | "print(x)\n",
272 | "print(y)\n",
273 | "print(z)"
274 | ],
275 | "metadata": {
276 | "colab": {
277 | "base_uri": "https://localhost:8080/"
278 | },
279 | "id": "2febQ37Dkq_u",
280 | "outputId": "a689e455-9ba9-4d83-8b86-7d8fe6b2241b"
281 | },
282 | "execution_count": 5,
283 | "outputs": [
284 | {
285 | "output_type": "stream",
286 | "name": "stdout",
287 | "text": [
288 | "Orange\n",
289 | "Orange\n",
290 | "Orange\n"
291 | ]
292 | }
293 | ]
294 | },
295 | {
296 | "cell_type": "markdown",
297 | "source": [
298 | "##Getting Address of a Variable\n",
299 | "Use id function for it.\n",
300 | "\n",
301 | "* The id() function returns a unique id for the specified object.\n",
302 | "\n",
303 | "* All objects in Python has its own unique id.\n",
304 | "\n",
305 | "* The id is assigned to the object when it is created.\n",
306 | "\n",
307 | "* The id is the object's memory address, and will be different for each time you run the program."
308 | ],
309 | "metadata": {
310 | "id": "JNNsoYZTp6FM"
311 | }
312 | },
313 | {
314 | "cell_type": "code",
315 | "source": [
316 | "X = 139810907914576\n",
317 | "print(id(139810907914576))\n",
318 | "b = 2\n",
319 | "print(id(b))"
320 | ],
321 | "metadata": {
322 | "colab": {
323 | "base_uri": "https://localhost:8080/"
324 | },
325 | "id": "Zoe2VvM1qClp",
326 | "outputId": "bb00facc-e68f-42ef-c924-f40682078f6e"
327 | },
328 | "execution_count": 14,
329 | "outputs": [
330 | {
331 | "output_type": "stream",
332 | "name": "stdout",
333 | "text": [
334 | "134382474229584\n",
335 | "134383037202704\n"
336 | ]
337 | }
338 | ]
339 | },
340 | {
341 | "cell_type": "markdown",
342 | "source": [
343 | "###Output Variables\n",
344 | "The Python print() function is often used to output variables."
345 | ],
346 | "metadata": {
347 | "id": "mtGY3g1ak1kw"
348 | }
349 | },
350 | {
351 | "cell_type": "code",
352 | "source": [
353 | "x = \"Python is awesome\"\n",
354 | "print(x)"
355 | ],
356 | "metadata": {
357 | "colab": {
358 | "base_uri": "https://localhost:8080/"
359 | },
360 | "id": "azAXQgfYk3gk",
361 | "outputId": "d378d936-9d66-4ac0-af04-d70bd05b3c91"
362 | },
363 | "execution_count": 6,
364 | "outputs": [
365 | {
366 | "output_type": "stream",
367 | "name": "stdout",
368 | "text": [
369 | "Python is awesome\n"
370 | ]
371 | }
372 | ]
373 | },
374 | {
375 | "cell_type": "markdown",
376 | "source": [
377 | "In the print() function, you output multiple variables, separated by a comma:"
378 | ],
379 | "metadata": {
380 | "id": "R3SnoGivk_MC"
381 | }
382 | },
383 | {
384 | "cell_type": "code",
385 | "source": [
386 | "x = \"Python\"\n",
387 | "y = \"is\"\n",
388 | "z = \"awesome\"\n",
389 | "print(x, y, z)"
390 | ],
391 | "metadata": {
392 | "colab": {
393 | "base_uri": "https://localhost:8080/"
394 | },
395 | "id": "3n8FG4yllBT-",
396 | "outputId": "9a2d7a11-fe99-4b7c-f904-2ba18114e7fd"
397 | },
398 | "execution_count": 7,
399 | "outputs": [
400 | {
401 | "output_type": "stream",
402 | "name": "stdout",
403 | "text": [
404 | "Python is awesome\n"
405 | ]
406 | }
407 | ]
408 | },
409 | {
410 | "cell_type": "markdown",
411 | "source": [
412 | "You can also use the + operator to output multiple variables:"
413 | ],
414 | "metadata": {
415 | "id": "adZHNMKqlLOH"
416 | }
417 | },
418 | {
419 | "cell_type": "code",
420 | "source": [
421 | "x = \"Python \"\n",
422 | "y = \"is \"\n",
423 | "z = \"awesome\"\n",
424 | "print(x + y + z)"
425 | ],
426 | "metadata": {
427 | "colab": {
428 | "base_uri": "https://localhost:8080/"
429 | },
430 | "id": "nbbORLG1lP_G",
431 | "outputId": "397ee84c-e786-4ecf-ef78-38d9684ebb40"
432 | },
433 | "execution_count": 8,
434 | "outputs": [
435 | {
436 | "output_type": "stream",
437 | "name": "stdout",
438 | "text": [
439 | "Python is awesome\n"
440 | ]
441 | }
442 | ]
443 | },
444 | {
445 | "cell_type": "markdown",
446 | "source": [
447 | "###End and Sep\n",
448 | "* We can use End command in the end of print function.\n",
449 | "\n",
450 | "* Syntax is: print(1,2,3,End=\" .\")\n",
451 | "\n",
452 | "* Sep command used to seprated the values from print funcction\n",
453 | "\n",
454 | "* Syntax is : print(1,2,3,4,sep=\"-\")"
455 | ],
456 | "metadata": {
457 | "id": "PntNa2ARlW4H"
458 | }
459 | },
460 | {
461 | "cell_type": "code",
462 | "source": [
463 | "print(\"Hello World\",end=\".\")\n",
464 | "print(\"\\n\")\n",
465 | "print(\"\\nHello\", \"World\", sep=\"-\")"
466 | ],
467 | "metadata": {
468 | "colab": {
469 | "base_uri": "https://localhost:8080/"
470 | },
471 | "id": "lqyIOfTBlcn1",
472 | "outputId": "0d23f54c-bb90-4236-bb85-933523c2ded9"
473 | },
474 | "execution_count": 13,
475 | "outputs": [
476 | {
477 | "output_type": "stream",
478 | "name": "stdout",
479 | "text": [
480 | "Hello World.\n",
481 | "\n",
482 | "\n",
483 | "Hello-World\n"
484 | ]
485 | }
486 | ]
487 | }
488 | ]
489 | }
--------------------------------------------------------------------------------
/Day_4(Data_Types_&_Type_Casting).ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "nbformat": 4,
3 | "nbformat_minor": 0,
4 | "metadata": {
5 | "colab": {
6 | "provenance": [],
7 | "toc_visible": true,
8 | "authorship_tag": "ABX9TyOH1gOywhFgl5vbRYApXLDX",
9 | "include_colab_link": true
10 | },
11 | "kernelspec": {
12 | "name": "python3",
13 | "display_name": "Python 3"
14 | },
15 | "language_info": {
16 | "name": "python"
17 | }
18 | },
19 | "cells": [
20 | {
21 | "cell_type": "markdown",
22 | "metadata": {
23 | "id": "view-in-github",
24 | "colab_type": "text"
25 | },
26 | "source": [
27 | "
"
28 | ]
29 | },
30 | {
31 | "cell_type": "markdown",
32 | "source": [
33 | "#Day_4"
34 | ],
35 | "metadata": {
36 | "id": "kgWao0b2nzao"
37 | }
38 | },
39 | {
40 | "cell_type": "markdown",
41 | "source": [
42 | "##Data Types\n",
43 | "* In programming, data type is an important concept.\n",
44 | "\n",
45 | "* Variables can store data of different types, and different types can do different things.\n",
46 | "\n",
47 | "Python has the following data types built-in by default, in these categories:\n",
48 | "\n",
49 | "1.Text Type: str\n",
50 | "\n",
51 | "2. Numeric Types: int, float, complex\n",
52 | "\n",
53 | "3. Sequence Types: list, tuple, range\n",
54 | "\n",
55 | "4. Mapping Type: dict\n",
56 | "\n",
57 | "5. Set Types: set, frozenset\n",
58 | "\n",
59 | "6. Boolean Type: bool\n",
60 | "\n",
61 | "7. Binary Types: bytes, bytearray, memoryview\n",
62 | "\n",
63 | "8. None Type: NoneType"
64 | ],
65 | "metadata": {
66 | "id": "0Wo6OYiCn32h"
67 | }
68 | },
69 | {
70 | "cell_type": "markdown",
71 | "source": [
72 | "### Python Numbers\n",
73 | "There are three numeric types in Python:\n",
74 | "\n",
75 | "1. int\n",
76 | "2. float\n",
77 | "3. complex"
78 | ],
79 | "metadata": {
80 | "id": "E9Mjku16oVZ2"
81 | }
82 | },
83 | {
84 | "cell_type": "code",
85 | "execution_count": 1,
86 | "metadata": {
87 | "colab": {
88 | "base_uri": "https://localhost:8080/"
89 | },
90 | "id": "KspGZ1sonlGc",
91 | "outputId": "a7189291-25cb-4d46-a9c7-2e260e9797ea"
92 | },
93 | "outputs": [
94 | {
95 | "output_type": "stream",
96 | "name": "stdout",
97 | "text": [
98 | "24 2.5 1j\n"
99 | ]
100 | }
101 | ],
102 | "source": [
103 | "x=24 #int data type\n",
104 | "y=2.5 #float data type\n",
105 | "z= 1j # copmlex data type\n",
106 | "print(x,y,z)"
107 | ]
108 | },
109 | {
110 | "cell_type": "markdown",
111 | "source": [
112 | "####Int\n",
113 | "Int, or integer, is a whole number, positive or negative, without decimals, of unlimited length."
114 | ],
115 | "metadata": {
116 | "id": "vCMFj9_qolKU"
117 | }
118 | },
119 | {
120 | "cell_type": "code",
121 | "source": [
122 | "x = 1\n",
123 | "y = 35656222554887711\n",
124 | "z = -3255522\n",
125 | "print(x)"
126 | ],
127 | "metadata": {
128 | "colab": {
129 | "base_uri": "https://localhost:8080/"
130 | },
131 | "id": "IqheeCldopER",
132 | "outputId": "1751a8e3-2f5c-4f54-8cff-4747e176420f"
133 | },
134 | "execution_count": 9,
135 | "outputs": [
136 | {
137 | "output_type": "stream",
138 | "name": "stdout",
139 | "text": [
140 | "1\n"
141 | ]
142 | }
143 | ]
144 | },
145 | {
146 | "cell_type": "markdown",
147 | "source": [
148 | "####float\n",
149 | "* Float, or \"floating point number\" is a number, positive or negative, containing one or more decimals."
150 | ],
151 | "metadata": {
152 | "id": "xorqNmHeosoW"
153 | }
154 | },
155 | {
156 | "cell_type": "code",
157 | "source": [
158 | "f1 = 1.10\n",
159 | "f2 = 1.0\n",
160 | "f3 = -35.59\n",
161 | "print(f1)"
162 | ],
163 | "metadata": {
164 | "colab": {
165 | "base_uri": "https://localhost:8080/"
166 | },
167 | "id": "JeuMicrqo1Bx",
168 | "outputId": "884cf4cf-ddd6-4e28-ee33-cdb96291fa13"
169 | },
170 | "execution_count": 8,
171 | "outputs": [
172 | {
173 | "output_type": "stream",
174 | "name": "stdout",
175 | "text": [
176 | "1.1\n"
177 | ]
178 | }
179 | ]
180 | },
181 | {
182 | "cell_type": "markdown",
183 | "source": [
184 | "####Complex\n",
185 | "Complex numbers are written with a \"j\" as the imaginary part:"
186 | ],
187 | "metadata": {
188 | "id": "-9AWXS5xpDC2"
189 | }
190 | },
191 | {
192 | "cell_type": "code",
193 | "source": [
194 | "c1 = 3+5j\n",
195 | "c2 = 5j\n",
196 | "c3 = -5j\n",
197 | "print(c1)"
198 | ],
199 | "metadata": {
200 | "colab": {
201 | "base_uri": "https://localhost:8080/"
202 | },
203 | "id": "24NSgJtgpEku",
204 | "outputId": "bd1efac3-fae2-4c44-ff97-f8bbddb6a4d6"
205 | },
206 | "execution_count": 7,
207 | "outputs": [
208 | {
209 | "output_type": "stream",
210 | "name": "stdout",
211 | "text": [
212 | "(3+5j)\n"
213 | ]
214 | }
215 | ]
216 | },
217 | {
218 | "cell_type": "markdown",
219 | "source": [
220 | "###Check Type of Data\n",
221 | "type() method used to check the type of data"
222 | ],
223 | "metadata": {
224 | "id": "u2OLiAP2phoM"
225 | }
226 | },
227 | {
228 | "cell_type": "code",
229 | "source": [
230 | "print(type(x))\n",
231 | "print(type(f1))\n",
232 | "print(type(c1))"
233 | ],
234 | "metadata": {
235 | "colab": {
236 | "base_uri": "https://localhost:8080/"
237 | },
238 | "id": "_BSN1QQUpku5",
239 | "outputId": "7f016950-c159-479d-e49d-a55e6da2c1f2"
240 | },
241 | "execution_count": 10,
242 | "outputs": [
243 | {
244 | "output_type": "stream",
245 | "name": "stdout",
246 | "text": [
247 | "\n",
248 | "\n",
249 | "\n"
250 | ]
251 | }
252 | ]
253 | },
254 | {
255 | "cell_type": "markdown",
256 | "source": [
257 | "##Input Function\n",
258 | "* Take Input from user"
259 | ],
260 | "metadata": {
261 | "id": "d9M_u6YWq7pP"
262 | }
263 | },
264 | {
265 | "cell_type": "code",
266 | "source": [
267 | "name=input(\"Enter your Name\")\n",
268 | "print(\"My Name is \",name)\n",
269 | "\n",
270 | "print(type(name))"
271 | ],
272 | "metadata": {
273 | "colab": {
274 | "base_uri": "https://localhost:8080/"
275 | },
276 | "id": "Vo2LBQwNrnvA",
277 | "outputId": "1cc074c6-efb1-465e-9fdd-f633b9a12761"
278 | },
279 | "execution_count": 11,
280 | "outputs": [
281 | {
282 | "output_type": "stream",
283 | "name": "stdout",
284 | "text": [
285 | "Enter your Namekousar raza\n",
286 | "My Name is kousar raza\n",
287 | "\n"
288 | ]
289 | }
290 | ]
291 | },
292 | {
293 | "cell_type": "markdown",
294 | "source": [
295 | "##String\n",
296 | "\n",
297 | "* String is a sequence of characters uncloased in quotes.\n",
298 | "\n",
299 | "* Strings in python are surrounded by either single quotation marks, or double quotation marks or triple quotation marks .\n",
300 | "\n",
301 | "* 'hello' is the same as \"hello\" and \"\"\"hello\"\"\".\n",
302 | "\n",
303 | "* You can display a string literal with the print() function:"
304 | ],
305 | "metadata": {
306 | "id": "W8tCf2WOsY6c"
307 | }
308 | },
309 | {
310 | "cell_type": "code",
311 | "source": [
312 | "a='hello world '\n",
313 | "b=\"hello world\"\n",
314 | "c=\"\"\"hello world\"\"\"\n",
315 | "\n",
316 | "print(a)\n",
317 | "print(b)\n",
318 | "print(c)"
319 | ],
320 | "metadata": {
321 | "colab": {
322 | "base_uri": "https://localhost:8080/"
323 | },
324 | "id": "wT3dTd1ess08",
325 | "outputId": "0f969059-6a3d-491e-bc18-8c9662f26973"
326 | },
327 | "execution_count": 12,
328 | "outputs": [
329 | {
330 | "output_type": "stream",
331 | "name": "stdout",
332 | "text": [
333 | "hello world \n",
334 | "hello world\n",
335 | "hello world\n"
336 | ]
337 | }
338 | ]
339 | },
340 | {
341 | "cell_type": "markdown",
342 | "source": [
343 | "###Strings are Arrays\n",
344 | " Like many other popular programming languages, strings in Python are arrays of bytes representing unicode characters.\n",
345 | "\n",
346 | "However, Python does not have a character data type, a single character is simply a string with a length of 1.\n",
347 | "\n",
348 | "Square brackets can be used to access elements of the string."
349 | ],
350 | "metadata": {
351 | "id": "CkNxAqy_syQi"
352 | }
353 | },
354 | {
355 | "cell_type": "code",
356 | "source": [
357 | "print(a[3])"
358 | ],
359 | "metadata": {
360 | "colab": {
361 | "base_uri": "https://localhost:8080/"
362 | },
363 | "id": "DMztmwNAu5Sy",
364 | "outputId": "f7df3737-e970-4ffd-e4b3-5aa4f72ca072"
365 | },
366 | "execution_count": 14,
367 | "outputs": [
368 | {
369 | "output_type": "stream",
370 | "name": "stdout",
371 | "text": [
372 | "l\n"
373 | ]
374 | }
375 | ]
376 | },
377 | {
378 | "cell_type": "markdown",
379 | "source": [
380 | "###Looping Through a String\n",
381 | "Since strings are arrays, we can loop through the characters in a string, with a for loop."
382 | ],
383 | "metadata": {
384 | "id": "Ok2GHk99vKbz"
385 | }
386 | },
387 | {
388 | "cell_type": "code",
389 | "source": [
390 | "#Loop through the letters in the word \"banana\":\n",
391 | "\n",
392 | "for x in \"banana\":\n",
393 | " print(x)"
394 | ],
395 | "metadata": {
396 | "colab": {
397 | "base_uri": "https://localhost:8080/"
398 | },
399 | "id": "a7Y4LPtvvPrI",
400 | "outputId": "59c97aa9-1d9e-44f8-ef15-6feb0866a661"
401 | },
402 | "execution_count": 15,
403 | "outputs": [
404 | {
405 | "output_type": "stream",
406 | "name": "stdout",
407 | "text": [
408 | "b\n",
409 | "a\n",
410 | "n\n",
411 | "a\n",
412 | "n\n",
413 | "a\n"
414 | ]
415 | }
416 | ]
417 | },
418 | {
419 | "cell_type": "markdown",
420 | "source": [
421 | "###Check String\n",
422 | "To check if a certain phrase or character is present in a string, we can use the keyword in."
423 | ],
424 | "metadata": {
425 | "id": "AWq2FRTsvdG6"
426 | }
427 | },
428 | {
429 | "cell_type": "code",
430 | "source": [
431 | "txt=\"Python Programming is easy to understand\"\n",
432 | "\n",
433 | "print(\"easy\" in txt)\n",
434 | "\n",
435 | "print(\"is\" not in txt)\n"
436 | ],
437 | "metadata": {
438 | "colab": {
439 | "base_uri": "https://localhost:8080/"
440 | },
441 | "id": "Hyc2TWo_vgOF",
442 | "outputId": "eb34a5ed-754d-405e-e5d9-d78b8888085d"
443 | },
444 | "execution_count": 17,
445 | "outputs": [
446 | {
447 | "output_type": "stream",
448 | "name": "stdout",
449 | "text": [
450 | "True\n",
451 | "False\n"
452 | ]
453 | }
454 | ]
455 | },
456 | {
457 | "cell_type": "markdown",
458 | "source": [
459 | "###Acces the element from String(Slicing)\n",
460 | "* You can return a range of characters by using the slice syntax.\n",
461 | "\n",
462 | "* Specify the start index and the end index, separated by a colon, to return a part of the string.\n",
463 | "\n",
464 | "Get the characters from position 2 to position 5 (not included):"
465 | ],
466 | "metadata": {
467 | "id": "qJ9feFBzwIYh"
468 | }
469 | },
470 | {
471 | "cell_type": "code",
472 | "source": [
473 | "print(a[2:5])"
474 | ],
475 | "metadata": {
476 | "colab": {
477 | "base_uri": "https://localhost:8080/"
478 | },
479 | "id": "KGlno5vdwmhT",
480 | "outputId": "a2f4ffe8-e15a-45a3-e20f-4972f20e459b"
481 | },
482 | "execution_count": 18,
483 | "outputs": [
484 | {
485 | "output_type": "stream",
486 | "name": "stdout",
487 | "text": [
488 | "llo\n"
489 | ]
490 | }
491 | ]
492 | },
493 | {
494 | "cell_type": "markdown",
495 | "source": [
496 | "#####Slice From the Start\n",
497 | "* By leaving out the start index, the range will start at the first character:\n",
498 | "\n",
499 | "* Example : Get the characters from the start to position 5 (not included):"
500 | ],
501 | "metadata": {
502 | "id": "ajy0c4t0wtwu"
503 | }
504 | },
505 | {
506 | "cell_type": "code",
507 | "source": [
508 | "print(b[:5])"
509 | ],
510 | "metadata": {
511 | "colab": {
512 | "base_uri": "https://localhost:8080/"
513 | },
514 | "id": "OnCpkXj3wwx2",
515 | "outputId": "26a1be87-e702-4ece-9b3c-3314db79229b"
516 | },
517 | "execution_count": 20,
518 | "outputs": [
519 | {
520 | "output_type": "stream",
521 | "name": "stdout",
522 | "text": [
523 | "hello\n"
524 | ]
525 | }
526 | ]
527 | },
528 | {
529 | "cell_type": "markdown",
530 | "source": [
531 | "####Slice To the End\n",
532 | "* By leaving out the end index, the range will go to the end:\n",
533 | "\n",
534 | "Example: Get the characters from position 2, and all the way to the end:"
535 | ],
536 | "metadata": {
537 | "id": "HLXILX6ixJaT"
538 | }
539 | },
540 | {
541 | "cell_type": "code",
542 | "source": [
543 | "print(c[1:])"
544 | ],
545 | "metadata": {
546 | "colab": {
547 | "base_uri": "https://localhost:8080/"
548 | },
549 | "id": "N4-EY4H_xNV1",
550 | "outputId": "4c995a7c-7b36-4f9f-cb71-273b150dfff0"
551 | },
552 | "execution_count": 21,
553 | "outputs": [
554 | {
555 | "output_type": "stream",
556 | "name": "stdout",
557 | "text": [
558 | "ello world\n"
559 | ]
560 | }
561 | ]
562 | },
563 | {
564 | "cell_type": "markdown",
565 | "source": [
566 | "###String Methods\n",
567 | "1. len\n",
568 | "2. upper\n",
569 | "3. lower\n",
570 | "4. strip\n",
571 | "5. count\n",
572 | "6. index\n",
573 | "7. split\n",
574 | "8. join\n",
575 | "9. capitalize\n"
576 | ],
577 | "metadata": {
578 | "id": "0Don-zX4xzbi"
579 | }
580 | },
581 | {
582 | "cell_type": "code",
583 | "source": [
584 | "name=\"paKistan\"\n",
585 | "sport=\" cRicket \"\n",
586 | "\n",
587 | "print(len(name))\n",
588 | "\n",
589 | "print(len(sport))\n",
590 | "\n",
591 | "\n",
592 | "print(name.upper())\n",
593 | "print(name.lower())\n",
594 | "\n",
595 | "print(sport.count('c'))\n",
596 | "\n",
597 | "print(sport.strip())\n",
598 | "\n",
599 | "print(sport.split())\n",
600 | "\n",
601 | "print(\"footbal\".join(sport))\n",
602 | "\n",
603 | "print(name.capitalize())\n"
604 | ],
605 | "metadata": {
606 | "colab": {
607 | "base_uri": "https://localhost:8080/"
608 | },
609 | "id": "clQiKPHRyjJl",
610 | "outputId": "4cbc3a80-ebda-4982-82a0-46e85dde7727"
611 | },
612 | "execution_count": 36,
613 | "outputs": [
614 | {
615 | "output_type": "stream",
616 | "name": "stdout",
617 | "text": [
618 | "8\n",
619 | "9\n",
620 | "PAKISTAN\n",
621 | "pakistan\n",
622 | "2\n",
623 | "cRicket\n",
624 | "['cRicket']\n",
625 | " footbalcfootbalRfootbalifootbalcfootbalkfootbalefootbaltfootbal \n",
626 | "Pakistan\n"
627 | ]
628 | }
629 | ]
630 | },
631 | {
632 | "cell_type": "markdown",
633 | "source": [
634 | "###String Concatenation\n",
635 | "\n",
636 | "* To concatenate, or combine, two strings you can use the + operator.\n",
637 | "\n",
638 | "\n"
639 | ],
640 | "metadata": {
641 | "id": "MpMlnBYN2FuT"
642 | }
643 | },
644 | {
645 | "cell_type": "code",
646 | "source": [
647 | "a=\"Hello\"\n",
648 | "b=\"World\"\n",
649 | "\n",
650 | "print(a+b)"
651 | ],
652 | "metadata": {
653 | "colab": {
654 | "base_uri": "https://localhost:8080/"
655 | },
656 | "id": "5oQlHbyD2RY7",
657 | "outputId": "0026778d-9ef3-46ce-c455-42a49fb189eb"
658 | },
659 | "execution_count": 37,
660 | "outputs": [
661 | {
662 | "output_type": "stream",
663 | "name": "stdout",
664 | "text": [
665 | "HelloWorld\n"
666 | ]
667 | }
668 | ]
669 | },
670 | {
671 | "cell_type": "markdown",
672 | "source": [
673 | "###String Format\n",
674 | "As we learned in the Python Variables chapter, we cannot combine strings and numbers like this:"
675 | ],
676 | "metadata": {
677 | "id": "eKxRwD917f3L"
678 | }
679 | },
680 | {
681 | "cell_type": "code",
682 | "source": [
683 | "age = 36\n",
684 | "txt = \"My name is John, I am \" + age\n",
685 | "print(txt)"
686 | ],
687 | "metadata": {
688 | "colab": {
689 | "base_uri": "https://localhost:8080/",
690 | "height": 210
691 | },
692 | "id": "FdklzQRg7iT3",
693 | "outputId": "e12edccb-6e7a-4394-d2b0-ddcf9999462b"
694 | },
695 | "execution_count": 1,
696 | "outputs": [
697 | {
698 | "output_type": "error",
699 | "ename": "TypeError",
700 | "evalue": "ignored",
701 | "traceback": [
702 | "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
703 | "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)",
704 | "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0mage\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;36m36\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mtxt\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m\"My name is John, I am \"\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0mage\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 3\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtxt\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
705 | "\u001b[0;31mTypeError\u001b[0m: can only concatenate str (not \"int\") to str"
706 | ]
707 | }
708 | ]
709 | },
710 | {
711 | "cell_type": "code",
712 | "source": [
713 | "age = 36\n",
714 | "txt = \"My name is John, and I am {}\"\n",
715 | "print(txt.format(age))"
716 | ],
717 | "metadata": {
718 | "colab": {
719 | "base_uri": "https://localhost:8080/"
720 | },
721 | "id": "9KOWb6qAQq2B",
722 | "outputId": "12f00bd6-1438-48ec-dcc2-99d25cf0cade"
723 | },
724 | "execution_count": 2,
725 | "outputs": [
726 | {
727 | "output_type": "stream",
728 | "name": "stdout",
729 | "text": [
730 | "My name is John, and I am 36\n"
731 | ]
732 | }
733 | ]
734 | },
735 | {
736 | "cell_type": "code",
737 | "source": [
738 | "quantity = 3\n",
739 | "itemno = 567\n",
740 | "price = 49.95\n",
741 | "myorder = \"I want {} pieces of item {} for {} dollars.\"\n",
742 | "print(myorder.format(quantity, itemno, price))"
743 | ],
744 | "metadata": {
745 | "colab": {
746 | "base_uri": "https://localhost:8080/"
747 | },
748 | "id": "F1XsyxATRGZV",
749 | "outputId": "3c4848cd-a0b1-490b-9856-e49e08bc327f"
750 | },
751 | "execution_count": 3,
752 | "outputs": [
753 | {
754 | "output_type": "stream",
755 | "name": "stdout",
756 | "text": [
757 | "I want 3 pieces of item 567 for 49.95 dollars.\n"
758 | ]
759 | }
760 | ]
761 | },
762 | {
763 | "cell_type": "markdown",
764 | "source": [
765 | "##Boolean\n",
766 | "* In programming you often need to know if an expression is True or False.\n",
767 | "\n",
768 | "* You can evaluate any expression in Python, and get one of two answers, True or False."
769 | ],
770 | "metadata": {
771 | "id": "Llzs8kORRe4D"
772 | }
773 | },
774 | {
775 | "cell_type": "code",
776 | "source": [
777 | "a=5\n",
778 | "b=10\n",
779 | "\n",
780 | "print(a==5)\n",
781 | "\n",
782 | "print(b==5)"
783 | ],
784 | "metadata": {
785 | "colab": {
786 | "base_uri": "https://localhost:8080/"
787 | },
788 | "id": "uEn3-8utRjUn",
789 | "outputId": "d13411a4-633e-49dc-d4a8-537d9a3e38a6"
790 | },
791 | "execution_count": 4,
792 | "outputs": [
793 | {
794 | "output_type": "stream",
795 | "name": "stdout",
796 | "text": [
797 | "True\n",
798 | "False\n"
799 | ]
800 | }
801 | ]
802 | },
803 | {
804 | "cell_type": "markdown",
805 | "source": [
806 | "##Type Casting\n",
807 | "\n",
808 | "* We can change the data type of a variable or a value.\n"
809 | ],
810 | "metadata": {
811 | "id": "wqSU1vhMR6EF"
812 | }
813 | },
814 | {
815 | "cell_type": "code",
816 | "source": [
817 | "a=5\n",
818 | "print(a)\n",
819 | "#type of a\n",
820 | "print(type(a))\n",
821 | "\n",
822 | "#change the type of a(int) to str\n",
823 | "\n",
824 | "b=str(a)\n",
825 | "print(b)\n",
826 | "print(type(b))\n",
827 | "\n",
828 | "#c=a+b\n",
829 | "#print(c)\n",
830 | "\n",
831 | "s=\"5\"\n",
832 | "sum=s+b\n",
833 | "print(sum)\n",
834 | "\n",
835 | "#chnage the str into float\n",
836 | "\n",
837 | "s=float(s)\n",
838 | "b=float(b)\n",
839 | "sum=a+b\n",
840 | "print(sum)\n",
841 | "print(type(sum))"
842 | ],
843 | "metadata": {
844 | "colab": {
845 | "base_uri": "https://localhost:8080/"
846 | },
847 | "id": "Dya0IGiOSM-u",
848 | "outputId": "840b0446-b071-4729-87e3-c94af2a5ccd0"
849 | },
850 | "execution_count": 12,
851 | "outputs": [
852 | {
853 | "output_type": "stream",
854 | "name": "stdout",
855 | "text": [
856 | "5\n",
857 | "\n",
858 | "5\n",
859 | "\n",
860 | "55\n",
861 | "10.0\n",
862 | "\n"
863 | ]
864 | }
865 | ]
866 | },
867 | {
868 | "cell_type": "code",
869 | "source": [
870 | "#Change float into int and int into float\n",
871 | "a=34.4\n",
872 | "b=40\n",
873 | "\n",
874 | "print(a,\"\\n\",b)\n",
875 | "print(type(a))\n",
876 | "print(type(b))\n",
877 | "\n"
878 | ],
879 | "metadata": {
880 | "colab": {
881 | "base_uri": "https://localhost:8080/"
882 | },
883 | "id": "nqe7smqzTjCH",
884 | "outputId": "07238fda-3dcd-43a0-bb7e-6891eda3f960"
885 | },
886 | "execution_count": 13,
887 | "outputs": [
888 | {
889 | "output_type": "stream",
890 | "name": "stdout",
891 | "text": [
892 | "34.4 \n",
893 | " 40\n",
894 | "\n",
895 | "\n"
896 | ]
897 | }
898 | ]
899 | },
900 | {
901 | "cell_type": "code",
902 | "source": [
903 | "a=int(a) #change into int\n",
904 | "b=float(b) # change into float\n",
905 | "\n",
906 | "print(a)\n",
907 | "print(b)\n",
908 | "\n",
909 | "print(type(a))\n",
910 | "print(type(b))"
911 | ],
912 | "metadata": {
913 | "colab": {
914 | "base_uri": "https://localhost:8080/"
915 | },
916 | "id": "k0KuJ02QT4yF",
917 | "outputId": "55810ef8-932d-443b-d1b7-f971b1853900"
918 | },
919 | "execution_count": 15,
920 | "outputs": [
921 | {
922 | "output_type": "stream",
923 | "name": "stdout",
924 | "text": [
925 | "34\n",
926 | "40.0\n",
927 | "\n",
928 | "\n"
929 | ]
930 | }
931 | ]
932 | }
933 | ]
934 | }
--------------------------------------------------------------------------------
/Day_5(Python_Operators).ipynb:
--------------------------------------------------------------------------------
1 | {
2 | "nbformat": 4,
3 | "nbformat_minor": 0,
4 | "metadata": {
5 | "colab": {
6 | "provenance": [],
7 | "toc_visible": true,
8 | "authorship_tag": "ABX9TyMgLIDr2bIXFnBMFPC+bZfU",
9 | "include_colab_link": true
10 | },
11 | "kernelspec": {
12 | "name": "python3",
13 | "display_name": "Python 3"
14 | },
15 | "language_info": {
16 | "name": "python"
17 | }
18 | },
19 | "cells": [
20 | {
21 | "cell_type": "markdown",
22 | "metadata": {
23 | "id": "view-in-github",
24 | "colab_type": "text"
25 | },
26 | "source": [
27 | " "
28 | ]
29 | },
30 | {
31 | "cell_type": "markdown",
32 | "source": [
33 | "#Day_5"
34 | ],
35 | "metadata": {
36 | "id": "yvb8Lz-6ZPCk"
37 | }
38 | },
39 | {
40 | "cell_type": "markdown",
41 | "source": [
42 | "##Python Operators\n",
43 | "* Operators are used to perform operations on variables and values.\n",
44 | "\n",
45 | "Python divides the operators in the following groups:\n",
46 | "\n",
47 | "1. Arithmetic operators\n",
48 | "2. Assignment operators\n",
49 | "3. Comparison operators\n",
50 | "4. Logical operators\n",
51 | "5. Identity operators\n",
52 | "6. Membership operators\n",
53 | "7. Bitwise operators"
54 | ],
55 | "metadata": {
56 | "id": "2gaNcxqheUwB"
57 | }
58 | },
59 | {
60 | "cell_type": "markdown",
61 | "source": [
62 | "### Arithmetic operators\n",
63 | "Arithnetic operators are used with numeric values to perform common mathematical operations:\n",
64 | "\n",
65 | "1. Addition(+)\n",
66 | "2. Subtraction(-)\n",
67 | "3. Multiplication(*)\n",
68 | "4. Division(/)\n",
69 | "5. Modulus (%)\n",
70 | "6. Exponentiation(**)\n",
71 | "7. Floor Division(//)\n",
72 | "\n"
73 | ],
74 | "metadata": {
75 | "id": "g55Ay1ble3YF"
76 | }
77 | },
78 | {
79 | "cell_type": "code",
80 | "execution_count": null,
81 | "metadata": {
82 | "colab": {
83 | "base_uri": "https://localhost:8080/"
84 | },
85 | "id": "ZVTIPfiReRfo",
86 | "outputId": "3a452767-b14a-4974-f790-73f909e13e4e"
87 | },
88 | "outputs": [
89 | {
90 | "output_type": "stream",
91 | "name": "stdout",
92 | "text": [
93 | "8\n",
94 | "3\n",
95 | "12\n",
96 | "2.0\n",
97 | "2\n",
98 | "9\n",
99 | "4\n"
100 | ]
101 | }
102 | ],
103 | "source": [
104 | "print(3+5) #addition\n",
105 | "\n",
106 | "print(6-3) #subtraction\n",
107 | "\n",
108 | "print(4 *3) # multiplication\n",
109 | "\n",
110 | "print(8/4) # division\n",
111 | "\n",
112 | "print(6%4) #modulus\n",
113 | "\n",
114 | "print(3**2) # exponentiation\n",
115 | "\n",
116 | "print(19//4) #the floor division // rounds the result down to the nearest whole number"
117 | ]
118 | },
119 | {
120 | "cell_type": "markdown",
121 | "source": [
122 | "### Python Assignment Operators\n",
123 | "Assignment operators are used to assign values to variables:\n",
124 | "\n",
125 | "1. =\n",
126 | "2. +=\tx += 3\tx = x + 3\n",
127 | "3. -=\tx -= 3\tx = x - 3\n",
128 | "4. *=\tx *= 3\tx = x * 3\n",
129 | "5. /=\tx /= 3\tx = x / 3\n",
130 | "6. %=\tx %= 3\tx = x % 3\n",
131 | "7. //=\tx //= 3\tx = x // 3\n",
132 | "8. **=\tx **= 3\tx = x ** 3\n"
133 | ],
134 | "metadata": {
135 | "id": "BDDJ2Jtchk22"
136 | }
137 | },
138 | {
139 | "cell_type": "code",
140 | "source": [
141 | "x=4\n",
142 | "print(x)\n",
143 | "\n",
144 | "x+=1 #same\n",
145 | "x=x+1 #same\n",
146 | "\n",
147 | "print(x)\n",
148 | "\n"
149 | ],
150 | "metadata": {
151 | "colab": {
152 | "base_uri": "https://localhost:8080/"
153 | },
154 | "id": "wMEClXXTi4U3",
155 | "outputId": "e2223b5c-35c1-400f-f538-3b4896c213a4"
156 | },
157 | "execution_count": null,
158 | "outputs": [
159 | {
160 | "output_type": "stream",
161 | "name": "stdout",
162 | "text": [
163 | "4\n",
164 | "6\n"
165 | ]
166 | }
167 | ]
168 | },
169 | {
170 | "cell_type": "markdown",
171 | "source": [
172 | "### Python Comparison Operators\n",
173 | "\n",
174 | "Comparison operators are used to compare two values:\n",
175 | "\n",
176 | "1. ==\tEqual\n",
177 | "2. !=\tNot equal\n",
178 | "3. > Greater than\n",
179 | "4. <\tLess than\n",
180 | "5. >=\tGreater than or equal to\n",
181 | "6. <=\tLess than or equal to"
182 | ],
183 | "metadata": {
184 | "id": "cEHAf2M9jgAv"
185 | }
186 | },
187 | {
188 | "cell_type": "code",
189 | "source": [
190 | "c=3\n",
191 | "d=4\n",
192 | "print(c==d)#equal\n",
193 | "\n",
194 | "print(c!=d)\n"
195 | ],
196 | "metadata": {
197 | "colab": {
198 | "base_uri": "https://localhost:8080/"
199 | },
200 | "id": "h81SuJ6Kj9sh",
201 | "outputId": "ca588705-7249-4eb6-b05e-3fba90aae5fb"
202 | },
203 | "execution_count": 2,
204 | "outputs": [
205 | {
206 | "output_type": "stream",
207 | "name": "stdout",
208 | "text": [
209 | "False\n",
210 | "True\n"
211 | ]
212 | }
213 | ]
214 | },
215 | {
216 | "cell_type": "code",
217 | "source": [
218 | "print(c>2)\n",
219 | "print(d<2)"
220 | ],
221 | "metadata": {
222 | "colab": {
223 | "base_uri": "https://localhost:8080/"
224 | },
225 | "id": "3bq0ngytYe50",
226 | "outputId": "d224e19f-0fdd-4400-a377-707dd7458bd2"
227 | },
228 | "execution_count": 3,
229 | "outputs": [
230 | {
231 | "output_type": "stream",
232 | "name": "stdout",
233 | "text": [
234 | "True\n",
235 | "False\n"
236 | ]
237 | }
238 | ]
239 | },
240 | {
241 | "cell_type": "code",
242 | "source": [
243 | "print(c>=3)\n",
244 | "print(2<=d)"
245 | ],
246 | "metadata": {
247 | "colab": {
248 | "base_uri": "https://localhost:8080/"
249 | },
250 | "id": "8xWV2smUYrQV",
251 | "outputId": "573faeee-79f9-44dd-b9d9-6737f371ba38"
252 | },
253 | "execution_count": 4,
254 | "outputs": [
255 | {
256 | "output_type": "stream",
257 | "name": "stdout",
258 | "text": [
259 | "True\n",
260 | "True\n"
261 | ]
262 | }
263 | ]
264 | },
265 | {
266 | "cell_type": "markdown",
267 | "source": [
268 | "###Python Logical Operators\n",
269 | "Logical operators are used to combine conditional statements:\n",
270 | "\n",
271 | "* and \tReturns True if both statements are true\n",
272 | "* or\tReturns True if one of the statements is true\n",
273 | "* not\tReverse the result, returns False if the result is true\tnot"
274 | ],
275 | "metadata": {
276 | "id": "Vv0-6XnRZDnW"
277 | }
278 | },
279 | {
280 | "cell_type": "code",
281 | "source": [
282 | "a=10\n",
283 | "b=100\n",
284 | "print(a==10 and b==100)\n",
285 | "print(10==12 and b==10)\n",
286 | "\n",
287 | "print(a>b or b!=a)\n",
288 | "\n",
289 | "print(b!=a or b:13: SyntaxWarning: \"is\" with a literal. Did you mean \"==\"?\n",
373 | "<>:13: SyntaxWarning: \"is\" with a literal. Did you mean \"==\"?\n",
374 | ":13: SyntaxWarning: \"is\" with a literal. Did you mean \"==\"?\n",
375 | " print(10 is e)\n"
376 | ]
377 | }
378 | ]
379 | },
380 | {
381 | "cell_type": "markdown",
382 | "source": [
383 | "###Membership Operators\n",
384 | "Membership operators are used to test if a sequence is presented in an object\n",
385 | "\n",
386 | "* in Returns \"True\" if a sequence with the specified value is present in the object\n",
387 | "\n",
388 | "* not in Returns \"True\" if a sequence with the specified value is not present in the object"
389 | ],
390 | "metadata": {
391 | "id": "i-4hRb7zePVP"
392 | }
393 | },
394 | {
395 | "cell_type": "code",
396 | "source": [
397 | "var1 = \"Python for Beginners\"\n",
398 | "print(\"y\" in var1)\n",
399 | "var2 = [\"orange\", 5, \"3.5\"]\n",
400 | "print(\"orange\" not in var2)\n",
401 | "\n",
402 | "print(\"O\" in \"iCodeGuru\")"
403 | ],
404 | "metadata": {
405 | "colab": {
406 | "base_uri": "https://localhost:8080/"
407 | },
408 | "id": "6PFTx-DLeUJq",
409 | "outputId": "335aceb6-68b3-4abb-f1cf-4b1cc65588fd"
410 | },
411 | "execution_count": 22,
412 | "outputs": [
413 | {
414 | "output_type": "stream",
415 | "name": "stdout",
416 | "text": [
417 | "True\n",
418 | "False\n",
419 | "False\n"
420 | ]
421 | }
422 | ]
423 | },
424 | {
425 | "cell_type": "code",
426 | "source": [
427 | "print(\"x\" not in var1)"
428 | ],
429 | "metadata": {
430 | "colab": {
431 | "base_uri": "https://localhost:8080/"
432 | },
433 | "id": "8Qf3HPvmee2n",
434 | "outputId": "a6b13505-20e4-4c20-8ba9-7e2f1942f3fe"
435 | },
436 | "execution_count": 23,
437 | "outputs": [
438 | {
439 | "output_type": "stream",
440 | "name": "stdout",
441 | "text": [
442 | "True\n"
443 | ]
444 | }
445 | ]
446 | }
447 | ]
448 | }
--------------------------------------------------------------------------------
/Exercise/Temperature_Conventers/Celsius_to_Fahrenheit:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/Exercise/Temperature_Conventers/CelsiustoFahrenheit.py:
--------------------------------------------------------------------------------
1 |
2 | #Enter Celsius Tempreature
3 | c=input("Enter Celsius Tempretaure")
4 | f=(int(c)+32)*(9/5)
5 | print(f)
6 |
--------------------------------------------------------------------------------
/Exercise/Temperature_Conventers/FahrenheittoCelsicus.py:
--------------------------------------------------------------------------------
1 |
2 | #Enter Fahrenhiet Tempreature
3 | f=input("Enter Fahrenheit Tempretaure")
4 | c=(int(f)-32)*(5/9)
5 | print(c)
6 |
--------------------------------------------------------------------------------
/Operators in Python/Arithmetic Operators/aaa:
--------------------------------------------------------------------------------
1 | print(3+5)
2 |
3 |
--------------------------------------------------------------------------------
/Operators in Python/Assignment operators/ath:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/Operators in Python/Comparison operators/asa:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Python(Zero to Hero)
2 | ## Week-1
3 | * Day-1
4 | * Day-2
5 | * Day-3
6 | * Day-4
7 | * Day-5
8 | * Day-6
9 | * Day-7
10 | ## Week-2
11 | * Day-1
12 | * Day-2
13 | * Day-3
14 | This repository is for python programmers.
15 |
--------------------------------------------------------------------------------
|