Complete Python programming from Python Basics to Advanced Python - Learn python from Scratch 2021 | Muhammad Hamza AbdulRehman | Skillshare

Playback Speed


  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x

Complete Python programming from Python Basics to Advanced Python - Learn python from Scratch 2021

teacher avatar Muhammad Hamza AbdulRehman

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Lessons in This Class

74 Lessons (4h 58m)
    • 1. Introduction

      2:02
    • 2. Code Editor PyCharm

      1:48
    • 3. PyCharm New Project

      5:14
    • 4. Jupyter notebook

      2:00
    • 5. Numbers

      5:52
    • 6. Variable

      2:59
    • 7. Strings and index

      4:01
    • 8. String Functions

      11:19
    • 9. Multiline strings in python

      2:08
    • 10. Strings concatination joining

      1:24
    • 11. Formatted f string

      2:35
    • 12. Special characters in python

      3:06
    • 13. Raw string in python

      4:57
    • 14. List Introduction

      4:37
    • 15. Functions on List

      7:24
    • 16. Nested Lists

      4:38
    • 17. Tuple Introduction

      4:32
    • 18. Tuple len and list

      0:55
    • 19. Mutable objects in a Tuple

      1:39
    • 20. Functions Introduction

      0:40
    • 21. Functions in Code

      5:24
    • 22. Nested Functions

      2:25
    • 23. Argument Types Explanation

      0:48
    • 24. Positional Arguments

      7:11
    • 25. Keyword Arguments

      3:10
    • 26. Multiple Arguments

      6:05
    • 27. Decorators Explanation

      1:54
    • 28. Decorators Code

      11:21
    • 29. Set

      4:49
    • 30. Loops Introduction

      0:39
    • 31. For Loop

      3:11
    • 32. For Loops Code

      4:00
    • 33. Task Tables App

      0:29
    • 34. Tables Task Solution

      6:49
    • 35. While

      7:30
    • 36. Conditionals Intoduction

      5:22
    • 37. Elif

      5:29
    • 38. File Handling Introduction

      2:53
    • 39. Read File

      6:07
    • 40. Try Except Python

      2:05
    • 41. With and Close

      2:21
    • 42. Write and Append

      3:19
    • 43. Count words

      3:08
    • 44. Task 1

      0:24
    • 45. Solution Task 1

      5:34
    • 46. Task 2

      0:18
    • 47. Solution Task 2

      4:46
    • 48. Make Connection and Create Table

      4:42
    • 49. Insert

      2:43
    • 50. Select

      8:55
    • 51. Where Clause

      5:28
    • 52. Delete

      2:14
    • 53. Update

      2:30
    • 54. Safety points try catch and ?

      5:52
    • 55. Regex Introduction

      2:28
    • 56. Raw String

      1:14
    • 57. Regex Code

      7:40
    • 58. SET and long string

      6:30
    • 59. Start and End

      5:51
    • 60. Match function and email validation

      7:41
    • 61. Task

      0:31
    • 62. Solution of Task

      3:12
    • 63. Findall Function

      2:59
    • 64. Finditer Function

      1:55
    • 65. Split Function

      1:16
    • 66. Class and Object

      4:10
    • 67. Class Code

      3:56
    • 68. Constructor of Class

      3:35
    • 69. Object Code

      8:13
    • 70. Inheritance

      3:35
    • 71. Inheritance Code

      5:24
    • 72. Abstraction Code

      3:50
    • 73. Polymorphism

      3:52
    • 74. Polymorphism Code

      6:21
  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels
  • Beg/Int level
  • Int/Adv level

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.

10

Students

--

Projects

About This Class

This course covers complete python programming from Python Basics to Advanced Python.

Starts with the basics of python like

Datatypes in python
Sequences in python
Functions
Nested Functions


In advanced section 

Database
File Handling
Regex
Decorators and more

This is for students completely new to programming and python.

Class Ratings

Expectations Met?
  • Exceeded!
    0%
  • Yes
    0%
  • Somewhat
    0%
  • Not really
    0%
Reviews Archive

In October 2018, we updated our review system to improve the way we collect feedback. Below are the reviews written before that update.

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.

Transcripts

1. Introduction: Salaam only com hide their peace and blessings, be upon Judea students, I welcome you to this complete Python programming course. Do you want to learn Python programming starting from basics and going to advanced topics? Or do you want to just want to start learning programming? Or do you want to upgrade your skills in Python programming by learning advanced topics? If so, then this course is for you. In advanced section, we will be learning about object-oriented programming, file handling, decorators, regular expressions, database, and more. So what if you are a beginner and new to programming? Don't worry, we will cover the basics of this language as well. The skills you've acquired in this course are not only restricted to Python programming, you can apply them in other languages like Java, C sharp, C plus, plus and more. So why learn Python? Whether it's a field of website development, data science, machine learning, game development, audition intelligence or data mining everywhere Python is a winner. So why this course, there are step-by-step tutorials and in-between, there are coding exercises that you can solve to make your skill stronger. And then now when you complete a task, I will give you a solution of that task as well. So if it's a complicated topic like class and object and object oriented programming or inheritance or polymorphism or encapsulation. We will cover these all. So if it is related to database or file handling, we will be working on these two and we will also look at regular expressions. So you will know how to write regex. So let's start this journey of learning Python programming. I'm looking forward to see you in this course as well. This truck with COVID-19. So be safe staying home and how tour. Thank you. 2. Code Editor PyCharm: Hi there. I welcome you to this course and I'm very happy to start this journey of learning Python programming with you. So the first thing to start with is the code editor. You can use any code editor of your choice. And if you have any code editor installed, you can simply go ahead and use that because our focus will be on code and code remains the same. So the code editor we will be using is Py charm. And the other ones you can look for is Jupiter notebook. It's a good one too, but mostly, and in this course we will be using PyCharm. So let's see how to download PyCharm. So you can simply go to Google and type. So this will open this jetbrains.com site link where you can go to this site and download this. We can also go directly to the download page, download PyCharm here. So here you can see I'm using Mac, so it, by default it has selected Mac. If you're using Windows, you can select windows here and download this community version of PyCharm because this is for pure Python development and it's free. So basically I'm using Mac, so I will select this one. And if you're using Linux, you can simply go here and download this community version. So on Mac, there are two options available. The DMV for Intel and Apple silicon. So Apple silicon is the new M1 chip that Apple has introduced. So my Mac is Apple silicon, so I will select this one and it will automatically start the download. As you can see here, it has started to download. And after the download completes, you can simply follow the steps for installation. And then we can move further with that code editor. 3. PyCharm New Project: So I have installed PyCharm and it shows me the screen after I installed it. So this is the Projects tab where my recent projects will go and all the projects which I have. So I I currently don't have any projects. Search shows nothing, so I can create a new project here from this New Project button. So I will click this and it shows me some options that I can name my project. So I will say learn Python. This will be the name of my project. I can add files into this project later on. So basically, you can leave other things as it is. And this is the interpreter. Data is basically used to execute our code. This interpreter reads and executes our code which we write in Python. So basically Python 3 is selected right now, which we will be using. And there are other options available like Python 2 and Python. We can add different interpreter versions here. So basically I will go with Python three and I will create this project. So yes, it will initialize this project now. And it gives me this screen here. So maybe when you are running it for the first time, interpreter is not installed. So what it will do is somewhere here it will show you an option Somewhere here to configure an interpreter. So you can simply go ahead and configure that and install that. It will actually put that interpreter injure BC and it will start working there. So without an interpreter, you cannot run this code. So basically this is some default code that they have given. I will just simply run it. So here we have this arrow button, green button, so we can use this triangle. But in to run any program and this window, this drop-down shows us that which, which file actually we have selected. So the mean is the file which is here in our project. So this learn Python is our main project where we have this main.out by this dot by extension is for Python files. So any file that is a Python file is a dot by extension. So basically this mean is a file. I will try to run this. And as you can see in the output window, this is the console window, the output window where our output will be shown. So it says high by jom, basically it reads this function and then this print statement. I will remove this default code because we have to start from the very start. So what I will do here is I will write a print command here, which will actually print. I am learning Python. So basically this message will be printed. So what this print statement does is it actually prints whatever I give it here as an input. It prints it here in the console window, in the output window. So when I run this, you can see it says I'm learning Python. So basically this main.py file is executed here to add an another Python file. What I will do is I will right-click my project and then new here we have the option to add a Python file. So basically I can click that and I have to name it. So I will say new file. So this will actually make a file that is with this name, new file. As you can see here, new file dot buy is made, and now I can write code in this file as well. So I will add an another print statement and it says New File. So now when I will run this here, so this is a mistake there usually people who are new to this and can make so I will guide you how to avoid this. So when I will run this, it will still be saying I'm learning Python. So why is it so Because I have in this file printed this new file. So basically we have not changed the file from here. So this main file is currently being executed here. So whenever I run this from here, it will execute this one. So this file is being executed. It says I'm learning Python to execute this file. I can right-click here and say Run new file, basically. So it will run this file now. So as you can see in the output, it says new file. So basically now it runs this file. And if I want to run this main file again, I will just say right-click and then run mean. So if it is changed here, then we can simply run it. And in the drop-down it will also show us both the files now. So the Eigen select new file from here, and then I can run it. And as you can see in the output, it runs my new file. So that's all from this session. 4. Jupyter notebook: So the other option that we can avail for good editor is Jupiter notebook. So you can just go to Google and type jupyter notebook. And it will show you in suggestions and then you can go to this Jupiter.org. So basically when you open this, you can scroll down and it says dry it in your browser or install. We will just go for it, try it in our browser. So basically it has a couple of 1000. So this dry classic notebook is for Python to read and just open this. And actually it is working now to just set up things and get things ready. So as soon as it completes, it will show us the code editor that we can simply use. So now good editor is opened, and as you can see this Run button here, but we don't have any file opened yet. So I will go here file, and I can say new notebook. And then for Python 3, so this will basically open a file for me. So now as you can see, it shows me this thing here where I can write code. For example, I say to any plus 7, and I will just simply breast this Run button on top. So it will give me the output that is 27 and the print statement that we used earlier for branding some output. I am learning Python. So basically what it will do is when I run it again, it will just show me that message. So we can go in here, we can write code here instead of other code editors. This is online. You can just go and start writing code there. So this is how you can use Jupyter notebook. That's all from this session. 5. Numbers: Hi there. In this session I will show you how to use Python as a calculator. Yes, we can use Python as a calculator or by applying different mathematical operations like addition, subtraction, multiplication on different datatypes. So I will add two numbers. For example, I have this number 30 and I can use this plus operator to add value in it. So I will say 20. Now actually when I run this program, I will see nothing and output because I have not printed anything. So I will go ahead and run this. As you can see, output is empty. I will try to put it in a print statements so that we can see its result in the output. So now I will run it. And as you can see, it shows 50. It has added these two values and I can add other values in it as well, for example, nine. So it will show me 59. Similarly as we have done addition, we can also do subtraction, for example, 30 minus 20. So the output should be 10. So as you can see in the output it stand. And we can also do multiplication. It is used to do multiplication. We will use asterisk sign, so which will actually multiply the values. So now it has shown us outputs 600, so it has multiplied these values. And to divide, we can use this forward slash. So it will actually divide these two values. And the result will be a float value, that is decimal point value, as you can see, 1.5. So the values that are completely divisible, for example, ten divided by two, it will still be converted into a floating point value. As you can see, it gives me 5, which is a floating point value. So now too, get rid of this decimal point values. We can just simply add an another forward slash here, which will actually remove the values after decimal point. So I will run this again, and as you can see, it shows me five. And if the value is not completely divisible, for example, 13 divided by 2, it will not show me the point values. So when I remove this, it will show me the point values again, as you can see, 6.5. So I can also add values in power. To do that, I will use double asterisk sign. Now this means that dean PO4 2. So it will give me some result that is 169. So if I replace it with 10 forward to it should give me a 100. As you can see in the output, it shows a 100. So this is how I put a value in a power. So now we can also get the mod operator. So I will add percentage sign here. So what it will do is it will give me the remainder value of this division. So actually in this case it will be 0 because there is nothing left in the remainder. So MOD operator is used to get that value. For example, if I change it to 13 divided by 2, so now it gives me one. So basically it gives me the remainder value there. I can group different expressions as well. For example, if I have a expression something like this, ten multiplied by 2 and then plus sign and five. So what it will do here is it will first of all multiply 10 by 2 because proceed and solve this multiplication operator is and this plus operator. So it will multiply ten AM with two and then add the value five, so which will give us 25 and the output, as you can see, 25 and the output. So if I change this to like this for example, to see that if it is multiplication is done first, I will just simply add this 5 first. So five plus ten into two. So the result will be same because the precedence of multiplication is high. First of all, it will multiply it with two and then add five. So as you can see, the result is same, but what if I want this expression to be evaluated first and then multiply it by two. So this is a lower precedence operator. What I will do here is I will put it in these two round brackets, which is called grouping. So I have grouped this. I have said that first of all, add these values and then multiply it with two. So now it will add five and 10, that is 15 into two with change our result, do tony, as you can see in the output. So this is how we can group expressions that are bigger in length and we can achieve the result that we want. So for example, at this multiplication sign has a higher procedures. So division sign also has a higher precedence than this plus and minus sign. So this is how it works. Here is an important point to note. If in any expression there is a float value, the output will be converted into float. So for example, if I have it 2, so now this is a float value in this expression. So now output will automatically be converted into float. So as you can see, it says 30. So this is how it works. So that's all from this session. 6. Variable: Hi there. In this session we will learn about variables. So I will go ahead and make a variable. I will name it fruit and put it equal to Apple. So now this is a string apple that I have put equal to this variable name fruit, and I can name it anything. For example, if I want to change it to my fruit, it will actually work. So this is our choice that what we name it. And by looking at the value of this variable, it will decide that what data type this variable has. So this, my fruit variable will be string now. So if I change it to 50, so now by looking at the value, it finds that it's an integer. So this my fruit variable is an integer now. And if I put it equal to a decimal point value, so it will actually change the datatype to float. So I will go ahead and make some other variables as well. For example, this is a fruit variable and I make another variable, let's say 50. And put it equal to 50, and then I can make 70 and put it equal to 70. It's a good thing to name a variable according to what value it has so that it actually speaks about the value. So it's a good practice there. So if I want to add these two values now I can use the variable name instead of the values directly. So what I will say is I will say some equals to 50 plus 70. So this will actually add this 50 into 70 and store this value and this new variable that is sum. So I will try to print the value of this sum variable. And let's look at the output. So actually it added 15 to 70, which is 120, so it printed. So for example, if I have this as a decimal point value, so now what it will do is it will convert it, the whole statement into a float value. So I will just run this. And as you can see in the output, we have got a float value there. The good thing about these variables is that we can reuse them in our code. For example, here, as you can see, I'm using the 50 variable here. I can use it somewhere else as well. For example, I say some two and put it equal to 50 plus 30. So now I don't have to just simply put the value there. I will use the variable name and add any other value which I have there. And when I print the value of sum to, it actually worked. So it increased the reusability that once I have made that variable, I can reuse them at different places. So that's all from this session. 7. Strings and index: Hi there. In this session we will learn about strings. String is basically a sequence of characters that are enclosed then either single or double quotes. So I will go ahead and make a string. I will name a variable here, strain, you can name it anything of your choice. Then I will add these single quotes here. And I will say, I am learning Python. So basically now this is a sequence of characters that are enclosed in single quotes, so it becomes a string. I can also enclose it in double quotes. So we can add a lot of characters in any string. For example, if I have and date of birth, I can put it equal to, let say, first jan to 1993. So now this string has some other characters like integers and things like that. So this 1993 is an integer. So when integer is enclosed in this double quotes or single quotes, it's also become a string. I can add other characters here as well. For example, desk string. And I can put it equal to, let's say, hash, dollar sign, percentage sign. So there are a lot of characters that we can include and make it part of a string. So it becomes a string there. Now, every character of this string is that specific index. For example, this eye is on 0 index and then this space is on one. And then this a onto. So I will go ahead and first of all, print this string, string on screen. Now, as you can see, the complete string that I'm learning Python is granted and if I replace it with date of birth, it will actually print that string here. So now what I will do is I will make it string again and then try to only print this I, which I have in this string. So it's on 0 index, so I will add the 0 index there. So when I will run it, as you can see, it gives me i what if I want to print this a? I will replace it with two. Yes, because I is non-zero, then this space is on one and then a is on two. So I will run this. As you can see it printed a there. So what if I want to print some part of string where we have some range of characters included. I can simply give a range here. For example, I can say start from 0 and end at seven. So now this is the lower limit from where I want to start and this is the upper limit. And we know that upper limit is not included, so it will go till six. So from 0 to six will be printed. And as you can see, it printed this I am learning. So what if I want to print this learning on Lee? So we can count the indexes. This is 0, 1, this space, and then this two, then three, and then four. So the L is on fifth index. I will replace it with five and where it ends 6, 7, 8, 9, 10, 11, 12. So it ends on 12. So I will use 13 instead. So I will add 13 because it will then take 125 to 12. So I will run this and as you can see it printed learning in the output. So this is how you can use indexes and bring different strands. So now we have some functions available on this string as well. So when I add a dot operator here, it shows me that there are a few functions that we can choose. So in the next session, we will learn about these. That's all from this session. 8. String Functions: Hi there. In this session we will learn how to apply functions on strings. So basically I have this string here. It says I'm learning Python, and in this line I'm printing that string in the output. Now, this is the name of variable string. When I add a dot operator after it shows me the functions that I can apply on this. So let's look at some of these. So if I say UPR, what it will do is it will make all the characters in this string uppercase. So now let's run it. And as you can see, everything is capitalized here. It's uppercase. Now what I will do is I will make this string. Some letters are capital and some are lowercase, some are uppercase. So I will call another function that is lower. So what it will do is it will make everything lowercase. Now as you can see, everything is lowercase in the output. So I will change it back and we can apply some other functions. There is an another function named split. What it will do is it will, by default, it will split this string on the basis of these empty spaces here inside. So it will give us a list. So as you can see, it returned us a list that is, I am learning and biotin as in separate strings basically. So we can apply the split function on different characters as well. For example, if I apply it on this E here, I can just simply go ahead and add that here. So now it will split this string on the basis of this E here, as you can see here. And It's skip that E and then give a returned us to bots they are. And if E exists somewhere else to, what it will do is it will split that as well as you can see in the output. Now, what I will do here is I will try to split it on the basis of some character. So I will add a colon sign here. Now what I'm seeing here is split this string on the basis of this column here. So like this. And when I will run this, as you can see, it returned me to strings and it divided the string on the basis of this column. So this is how split works. We have some other functions like capitalize. What it will do is it will capitalized uppercase the first character in this string. So I would run this. And as you can see here, the eye is uppercase now. So basically I will remove this column sign now. So I can also check that whether this string starts or ends with something like for example, I can say starts with and then I can provide a string. For example, this string start with I. So what I can do here is I can put I and it will return me a Boolean, true or false, that whether this is the case or not. So it says true. Yes. It started with I so if I change it to anything else, what it will do, it says false. So I can also provide multiple characters here. For example, I space M, L, E. So now this should also give me Drew. And if I remove this space here now it doesn't exactly matches our search, so basically it will say false. Now I can also check the ends with here. There is an another function ends with. So basically it will be working same for the characters at the end, for example, eyes with Python. So this string actually ends with Python. So basically it should return true as you can see in the output. And if I change it to something else, for example, like this, it will say false. Now there are other interesting functions as well. Let's see. So when I do this daughter bridge or I can check if this string is a numeric or not. For example, if I have a numeric string, which is equals to, let's say 77. Now, I will check for this string first of all, so I can see is numeric. So basically it will tell me if it is numeric or not. So when I run this, it says false because our string, this one is not numeric. When I replace it with this string here and run, it says true because this is in numeric string here. So now what I can do here is I can also check whether this string is lowercase or uppercase. So I can say is lower. So basically it will return me true. And if there is any character that is uppercase, it will return me falls, as you can see in the output. So I will remove this and check. We can also check if it is upper. So basically it will. Say false here because this string is not upper, it is lower. We can also get index of any specific character in my string. So in my district, I can use a function index and I can say I here. So I will give me the index 0 because i is non-zero index. So as you can see, it's a 0 and the output, and if I change it to be, it will be me for Dean, its own 14th index. And then if I change it to a, is the index number of a is two. So it should give me two, as you can see in the output. And now I can also find is specific series of character in my string. So I can do that by using Find function. So what fine we will do is it will find this series of characters or a single character in my string. So when I will run this, as you can see, it says it's on index two. So if I change it to learning here. So when I run this, after doing this, It says it, it's on fifth, starting from the fifth index here. We have that in the string. And if I change it to something else that doesn't exist, it will not show me anything. It's the minus one will indicate that it's not there. So by this, I can check if that string is there and starting at which index there. So now there is an another function I will show you that it says contained. So what it do is it will actually tell me that whether it's specific part of string is there or not. So I will say m. So this will actually, when I run this, it says true. So it's Boolean return or that whether they exist or not. So the previous function was given to us, the index as well. It was saying, Okay, That string is there. The index number from where it starts is this one. But we can use this contains if we only wanted to check whether this is in there or not. So I will say Python. So run this. It is true. If I change it to, let's say C plus plus, it will say false because C plus plus is not there, right? There is an another interesting function that I can use that is the count function. So what count function does is it actually finds the number of occurrences of any character or series of characters in my string. So I will give this count function, let's say i. So what it will do is it will count the number of occurrences of I. So I is 2 times in this string. When I run this, as you can see, it says two and when I change it to m. So it should say three times, as you can see here in the output. And if I change it to a, it will say do dimes because a is two times in my string. So what if I change it to any character that is not there, for example z, so this is not there, so it says 0 times. Now I can also give a series of characters that is, for example, by tons. So how many times biotin is there in my string? It's one dime. So when I run this, it saved me one. Now I will increase it to do dimes. Python is good. So now Python is due time. So when I run it, it actually shows me two there. So we can search in different strings that how many dimes, different characters or series of characters are there. So now I can also restricted to specific range. For example, I only want to search in this area not on the complete string. Maybe my string is bigger and I want to search at some specific part of it. I can also do that by giving the starting and the ending index they are how I can do that, I have to add a comma here and then I can pass in the other argument like the starting index, for example, I want to start from 0 that is here, and then I want to go somewhere around here. So what I will say is I will say, okay, search it for like 20. So now it will take the starting index as 0 and then the final index, the uppercase will be 20. So it will take the 19, It will go until 19th index. So now when I will run this, as you can see, it says one time. So in this specific range, it occurred one time. And if I change this range, I increase this range. So now as you can see, it do dimes because this python also completely fit in that range. So this should completely fit in that specific range that we specify there. So for example, if I add an another Python here and change it to something like 10. Now it's one time in 10. And when I change it to 20, It's still one time. If I change it to 30, It's due dimes and if I change it to 40, it will actually say that it's three times in there. Now what if I search for this learning here? Let's see. As you can see, it says it's, it has a good one time in this string. So that was with the functions. You can try different functions and practice that in the name of the function. Usually see is what it actually do. Search very easy to understand because most of the functions, their name, naming convention is good and we can understand it through that. So that's all from this session. 9. Multiline strings in python: Hi there. In this session, I will guide you how to write multiline strings in Python. So I will go ahead and make the variable multiline string. Now to write a multi-line string, I have to add three quotes, either single or double quote doesn't matter, so I will add three single quotes here. Now, this means in the starting I have three single course and in the end I have three single goat. It means that now this is a multi-line string. I can add anything inside it with multiple lines. For example, I have some fruits, Apple, mango, and orange. So now when I try to print this string, it is very able. What it will do is it will actually bring my multiline string here and the output as you can see. So what if I change it to three double quotes instead of single quotes? It's, it's fine. It's actually the same patron here. So I will cut this from here and put it here. Now this is fine. And when I run this, it actually works. Now if I change it to a normal string where I have only one code, it will show me an error because one quote string can be on the same line and it is only one line string. And to get multiple lines on the single, that is only one God, we have to use the special character and we will talk about that in our upcoming session. So when I run this, as you can see, it says end of line while scanning string literal. So it doesn't find it. It has to be in the one line. So it says the end of line and there was no closing quote for dad. So this shows me an error. So now to make it multiline, I will just add these three quotes again and in the end as well. So now this is fine and we can write multiline strings and biotin like this. So that's all from this session. 10. Strings concatination joining: Hi there. In this session, I will guide you how to join strings. So I have these two strings here. The first strengths is learning and the second strength is Python. I can simply join these strains by using the plus operator. So I will make a new string joint string and I will put it equal to four strain plus operator and then the second string. So this will actually join these two strings. And to see that I will just print my, this new string, join string and we will see in the output what it has. So as you can see, the two strings are joined together. We can go ahead and add a space in between by doing like this. Now what I did is I added a empty space between these two strings. And I can keep on adding strings, joining strings by using this plus operator. So what if I wanted dot a string at the end? So now what it will do is it will add a space in between and then the dot string at the end. So when I run this, as you can see, it says learning Python and there is a space in between. So we can keep on adding and joining strings together by using this plus operator. So that's all from this session. 11. Formatted f string: Hi there. In this session I will show you another way of joining strings. So previously we did it with blood operator. Now we can also do it with the formatted string. So we have this formatted string in Python and I will show you how to do that. So I will make an, another variable joined string, and that will be f string. So basically what I have to do is it is normal string. Basically we can add double quotes or single quotes. So I will add this single quote. And before starting off that string, we can write f here. So this F means now this is a formatted string and it has some Patron. So basically if it is a normal string, I am learning. I say I am learning, we can add this and wherever we want to put a variable, it will be inside these two curly braces. So now if I want to add this Python here, so this is in the second string. What I will do is I will add it here. So now I will just try to print this in the output. So I will replace this with this one, and I will run this. As you can see, it says I'm learning Python. So despite them came from this variable which we have. And now as this is the f string, so it did that. If I remove this f from here, what it will do is it will create it as a normal strain now. And if I put it here, so it will become a formatted string. I can also replace it with the capital F. It will work fine. So the idea here is that every variable goes inside these curly braces. So now what if I want to print this? I want to join these two strings. What I will do is I will simply say, okay, first of all, we have this variable. First of all, I will remove this. And then we have this first variable, that is first string, and then we have some space, and then the second variable. So like this, when I run this, as you can see, it joined our string and added a space and we can add anything after that as well. Learning Python is fun. So when I run this, as you can see, it takes the variable value where we have this curly braces and then we have this normal string. It actually put it as it is. So this is how we worked with the formatted f string. That's all from this session. 12. Special characters in python: Hi there. In this session, I will guide you about some special characters in Python. So for example, I have this names string and it has few names. Or Amman Muhammad, john, Hamza, and P2. So what I will do is I will try to bring this. And when I brand is, all of these are in same line. So what if I want all of the names to be listed out not in the same line but in the separate lines. So what I can do here is I can use a special character here that is backslash and then m. As you can see, it changed the color of backslash n because it's a special character and what it means is new line. So it will actually shift everything after that in a new line. So when I run this, as you can see, reminisce on the top line, and then we have a space before Muhammad, and it's in the second line width that space. So if I remove this space here, it will actually be in the same line as you can see here. Now, Eigen do this for all the other here. And every name will be on the separate line, that is new line. As you can see the output every name in new line. So this is for the new line. And if I add backslash d, it will actually give some distance in between DHAP. So I will run this. And as you can see, Raymond and muhammad have one space that is here and the other one for the tab. So if I remove this space here and around this, as you can see still there is some space between Raymond and Muhammad, if I add it a few times. So what it will do is it will add that space there. You can see it added that space, which I did it from the special character data I have here. There is an another special character that is backslash r, r for return. So what I will do here is first of all, I will make this thing like this. So I will run this. And now I can put this Hamza and Peter on a same line. So I will actually remove this backslash. And here, and as you can see, Hamza and Peter are on same line. So what if I want to reject everything before some value, for example, before Peter, I want to reject everything on that particular line. So I want to remove this Hamza. So what I can do here is I can say backslash. Our return to what it will actually do is it will remove everything on that line before Peter. So as you can see, only beater is there. And if I put this backslash r here instead of here, it will actually only show E and R there. As you can see, E and R is 0. So these are some special characters that we can use. That's all from this session. 13. Raw string in python: Hi there, Welcome to this session. I have this name string here where we have some names and this backslash and special character that actually puts every name on a new line. So what if I don't want this backslash and to me for a new line, and I want it printed as it is in my string. So what it, how I can ignore its functionality. What I will do here is I will add in another backslash. So when it encounters this backslash now it will not activate the working of this new line operator. So when I run this, as you can see, the backslash n is added to my string as it is in the output. And similarly, I can do it with the other special characters here. So everything will be included now, so it will ignore the functionality of this backslash n. So this is how we can just simply ignore the functionality. There is an another way of doing it as well. So I can simply do it by a raw string. So how I will add a r here simply at the starting of the string, which will actually apply it to everything. So when I run this, as you can see, it gave me the same result. Now rostering is always adjust the complete string as it is, whatever inside. So I can just simply replace it with the capital R and it will have the same functionality. Let's look at an another case. For example, we have a string like this. Now this string is absolutely fine. We have double-quotes and closing this string and then we have this single code there inside our string. So when I print this string, it will go fine and it will actually print out that value there. So what if I change these double-quotes, two single quotes? Now, here comes the issue. So what is the issue? It thinks that this code and this code is the enclosing coats of the string because this is used for enclosing the string. Now it has some error here that it doesn't recognize that what syntax we are using here. So when I will run this, as you can see in the output, it says invalid syntax. So here is a problem. I can not convert it into a raw string to avoid that, because it will assume that this string is ending here. So what I can do here is I can simply use the previous technique, that is the backslash. So by adding this backslash, it will bring this code as it is, instead of activating its functionality, that is, to enclose a strain. So when I run this like this, now it's absolutely fine and it allowed us to use that single core inside our string. So let's look at an another example. For example, I have a string and this is a coat of somebody. What I see, he says. And then when I will try to add these two cords, it will show me some error because, okay, learning Python. Learning Python. Now it's an issue for this interpreter because these courts are used to enclose the string and inside string, I'm using this as a quote off somebody. So when I run this, it will again show me an error. It says invalid syntax. Now simply what I have to do is I have to add these back slashes for these goats to be ignored. And now I can simply use that. So he says learning Python. And if we have single quotes and closing this string, then that is not required. So what I can do here is single quotes and then the double-quotes inside. So this will actually do the job for me. But what if I have this single quote as well? So then I have to use them. For example, if I join this string here in the start, and then I add this dot operator. Now, if I remove this thing now this is an issue here. So somewhere, if we are having both these double quotes and single quotes inside a single string, we will have to skip it somewhere, for example, like here, because the enclosing quotes or single, so I have to skip the functionality of single quotes inside and double-quotes will be fine here. So when I run this, as you can see, it actually do the job here. So this is how we deal with strings. And in this session we learned about raw strings and how to add different special characters by using backslash in our string naps. All from this session. 14. List Introduction: Hi there. In this session we will learn about list. So I will go ahead and make a list. I will call it list of integers. So basically this list of integers will be a list where we have integers inside. So to initialize a list, what we do is we add these two square brackets and every element of this list goes inside these two square brackets. So as this is a list of integers, so I will go ahead and add some integers here. So that's 67. So now this is a sequence where every element is at specific index. So basically listed a sequence and every element is that specific index. For example, this 17 is at 0 index and this is on one and so on. So what I can do is how I can assess these elements is by writing the index number. So I will try to bring this list first list of integers, and I will run this. And as you can see in the output, my list is entirely printed. So what I will do here is I will try to print this value of my sequence. So how I can assess this, this one is on 0, this one on one, and this one on to. So what I will add here is square brackets. And inside these, I will specify the index number. So this is two. So I will try to run it. And as you can see in the output, it gives me 4. And how I can assess this 17, I will write 0 here, which will actually give me the 17 value, as you can see in the output. Now, there can be different data that we can put inside a list. For example, I will go ahead and make a list of strings and put it equal to some fruits, for example, Apple, mango, and let's say orange. So now this list is a sequence of strings where at every particular index we have a string. For example, at index 0 we have Apple, and at index one we have mango and so on. So how we can assess this, I will actually write the name of my list that a list of strings. And then on the 0 index, I have this apple there. So when I will run it, as you can see, I got this apple there. And if I change it to one, it will give me mango, as you can see in the output. So we can put different data types inside list. I will go ahead and make a list of float lives of fluid and put it equal to some decimal point values. For example, 77.753.7. So now this is a list of fluids. And if I tried to print something of this list, I will get the value same as I did for the other lists. So by doing this, we get the value at index one and dad is 53.7. So it printed that value in the output that is 53.7. So now there is an another interesting thing. We can have list with different datatypes. For example, I will name it, list mixed. So basically this list will be, will be having different data type. For example, let's say the first one is integer, the second one is string, and the third one is float. And the other one, a Boolean may be. So now as you can see, this list has different data types. So this list is a mixture of different datatypes. We can make lists like this as well. So when I will try to print the list, list mixed values, it will actually do, for example, on index one we have this Hamza, so it printed in the output. And now on index, what we have is we have this float value and I will try to run this as you can see. And the index number 3, we have this drew dad is a boolean, right? So actually it printed that. So this is a benefit of list. We can have different data types inside a list. And so this is basically a sequence where every element is at particular index. So that's all from this session. 15. Functions on List: Hi there. In this session I will show you how to apply different functions on lists sequence. We did it previously with the string sequence, we apply different functions on string. Similarly, we can do this with list as well. For example, when I write the name of this list and add this dot operator, as you can see, it shows me a list of functions that I can apply on this list. So I will try some. So what if I want to sort this list? As you can see, this list is not sorted. So I will call the sort function here, which will actually sort this list. And I will try to print this list now to see the output. And when I run this, as you can see, the output list is sorted. Now. Now what if I want to reverse this list, the sequence? So what I will do is I will call the reverse function here. So when I run this, as you can see, my list is reversed now the last index value is on the first index now. So there is another weekend, add, delete values from this list as well. There is a function append that will actually put a value in the end. For example, I have this value, apple here. So what it will do is it will pick this complete value there and put it in the last index, which I have there in my list. So when I will run this, as you can see, the last index data is the new one is now the apple. What if I don't want to put this value completely at the last spot. But what I wanna do is I want to put every value in this sequence, that is my string sequence on a separate index. So I will just do replace it with extent, which will actually pick every value at a particular index in this sequence and put it there at different spots. So when I run this, as you can see, all the values in my Apple sequence, that is a String sequence is on separate index now, so for dad, we then use extent. I can also put this value at some specific index data I want, for example, I don't want this to be on the last index, I want it on the first index. So what I will use is I will use another function named Insert. Now this function allows me to put this value at any index off my choice. So I will first of all specify the index data 0 in my case, and then this comma, and then the value which I have here. So what I'm seeing here is at this index 0, put this value. So when I will run this, you can see apple is on the index 0 in my list. Now if I change it to three, from this 0 to three, it will put my value at the third index and move every other value one step forward in that sequence. So if I want to remove some value from my list, Eigen also do that by using the Remove function. So I say remove the value two from my list. So now the new list which I have here doesn't have the value two. And if I say okay, remove a seven. So it will actually remove seven. Now the list starts from five. So what I will do is we can also clear this complete list. So if you call this clear function here, it will actually remove every value. As you can see, the output list is empty. Now, I can also see whether a particular value is there or not. So I will use this contains function. I will just remove this here and say list dot contains. So now this function will return me that whether that particular values, they are not. For example, I say a 100. If 100 is there. So it will give me true. And if it's not there, for example, 200. So what it will actually say is false that this value is not there. I can also get in to see that values at which particular index. So for dad, I will call the index function. So I will say nine here. So what if this value is not there? If this value is there, it will give me an index. Otherwise, it will give me a value error. That particular value is not there in that list. So first of all, every run it like this. As you can see, it says index three. And if I say seven here, we'll say index 0. So seven here. Now when I run this, it says on index 0 and if a value is not there, for example, 700 not this will give me a value error. How we know that we can just hover over this function. And as you can see, you can read this. It says return first index of value. And then in the second line it says raises value error if the value is not present. So when I will run this, as you can see, it gives me a value error here, that 700 is not in the list. We can also search it in a specific range. For example, I only want to search in this particular range and not the complete list at whether the first few elements contain this value or not. So I will, I can specify the start and the end index after this, for example, 700 and arrange starting from 0 to three. So 700 is not there, so still it will give me a value error. And, but if I put five-year, now five is there in my range of index from 0 to three, right? So when I will run this, it gives me one. So it says, yes, it is on index one, this value. So this three, we know that the upper limit is not included there. So what I mean by here is so this is on 0123. So which means that this third index value will not be included. It will just assertion this part here. So if I search for nine, it will show me a value error because we know that the upper index is not included. So as you can see, it gives me a value error because this nine was on the index three and the upper limit is not included. So if I change the upper limit from three to four here, what it will do is, it will now give me the value of the index of that. It says it's an index 3, that particular value, right? So that's how we can specify a range in between. We want to search for a particular value. So now there is an another function that will give me a count of a particular value in any sequence. So in this particular list sequence, so I will say count and I will say nine. So tell me how many times does nine is there in this list? I will run this and it will tell me. It says, okay, it's one time. And if I added more times, like now, it's two times, so it says two and if I increase the value, it will actually give me the count of that particular value there. So now it's three. So it shows me 3. So that's how we can use different functions on list. That's all from this session. 16. Nested Lists: How about having a list inside, in another list? Yes, that's true in Python, we can have a nested list. So we have learned about list with different datatypes. So now what we can do is we can also have an another list inside a particular list. So what I will do here is I will remove this part here. And this one just focus on this list which we have here. Here we have this string which is also a sequence. So why not other sequence as well? So I will go ahead and add an another list inside this list that we'll actually have some integers. So basically now on index 0, we have this index one, we have this index 2, we have this and index 3, we have this complete list. So when I will try to print the index 3 value here, what it will do is it will give me this complete list because this list is on index 3. When I run this, as you can see in the output, it gave me complete list at this particular index. So now here's a question that how I can assess elements inside this list, for example two or for example a in this orange and this mango. You can just pause for a while and think about it. So now, Okay, I will give you the solution for this. To assess the elements inside the sequence at particular index, what we will do is we will add another two square brackets and specify the index number. So now we're saying, okay, on index number 3, that is this one. We have three indexes available, 0, 1, and 2. So if I want to assess this three here, I will write to. So basically the second index I'm saying on the third index of the outer list, go to the second index of the inner list. And when I will try to run this, as you can see, it gave me a three. And what if I have an another list at that particular spot rather than just a simple value, just reagan do that as well. So I will go ahead and add some floats there, 77.7 and maybe in another string because list can be of different data types. So I will say John. So now at this index, now we haven't another list when I will try to bring this like this with this values, it will actually give me this nested list which we have there. So when I run this, as you can see, it gave me the list that was at that particular spot. Now inside that list, I can also get a particular value. To do that, I will add another square bracket that will actually give me access to the inner values. So when I write one here, it will actually give me this John value which is here. So now when I run this, as you can see, it says John, and John is itself, is sequence, write strings are sequences. So what if I want to assess this h here? I will add another square bracket and specify two here. Now what I mean by this is the value on the index to that is age. So when I run this, as you can see, it gave me an edge. So it's basically nested list and we can keep on putting in nested lists inside there. And it works like this. We can keep on adding these two square brackets and specifying the index number. So how I can assess this p here in this Apple? First of all, what I will look for is the outer list. So this is the outer list. Where is Apple and outer list? First of all, I have to figure out that it is on the end is 0. So I will remove this part here and this one too. So first to fall 0 index value, that is Apple. I will run it and it will give me apple. Now to assess this P, what I will do is I will add another square bracket and we have two pi's there on 12. So I will print the value. So now it will give me that b here. So this is how nested list works. We can add another, we can add different datatypes as well, like tuple, tuple that we are going to discuss in our upcoming sessions. So for now, that's all from this session. 17. Tuple Introduction: Hi there. In this session we will learn about tuple. Tuple is in another data type in Python that we can use. So let's understand it with an example. So we have a list here which has some values. And what I'm doing here is I'm saying, OK, at the index 0, change the value from seven to 700. I'm assigning the value and then bringing my list. When I run this, as you can see, the value at 0 index is replaced from seven to 700. Now to convert this into a tuple, what I will do is I will remove these two square brackets. Now this converts it into a tuple, right? Do you BLE tuple? I can do it with two ways by removing the brackets or by adding the round brackets here. So basically tuple is in round brackets, but while assigning it and initialize them yet I can just ignore these brackets as well. So there is an important thing about tuple that it is immutable. We cannot change values, we cannot add values in this, as we can do with the list. So this thing was working very fine with the list, but when I do it with tuple, so this is now an issue here because we cannot change values in tuple. So I will just try to print this and we will get an error here that is the type error. Tuple object does not support item assignment, so we cannot assign this value if I remove this part here and only print the tuple, it, it actually prints this. So if I remove these round brackets as well and run this, as you can see, it's still made it a tuple. So data, that's how we make a tuple and we can assess different values of tuple as we did with the list. So assess a value, we will add two square bracket and then the index number, let's say 0. So it should give me seven, as you can see. And if I change these indexes from 0 to four, it will actually give me a value on dad index. And there were different functions that we were applying on list. So now just add a dot operator and as you can see, it shows us the count and the index function there and all other functions like append, extend and insert. They're not here because it's immutable and we cannot change values or add values. So if you want to use this function count, it will actually tell us the number of occurrences of that particular value. For example, five here, it will save one, as you can see. And if we add an another five here, so it will now say two dimes. Now there is an another function that we can use that is index, which will actually give the index of particular value. For example, five, it's on index one, the first occurrence of that value. So it says one. So it ignores the second occurrence of that value. As soon as it finds a value in that a tuple, it will actually give us that. And we can also specify a range in which we want to start searching. For example, we only want to search in this range. So starting from 0123 and the fourth index, because we know the upper limit is not included. So 0 here and then four. So basically it will give me this five in this range now. So when I will run this, as you can see, it says one time it is there. So if I change the starting range from three to four, what it will do, it will not give me, it will give me a value error that this x is not in tuple. So basically this is how we can apply this function on tuple. We can also see whether a particular value is invertible or not. For dad, what we'd induces the contains function. So now it will tell me that if the value is there, so if I add 30 year and run this, as you can see, it says true because 30 is there, but 300 is not there. So when I run this, it says false. So this is how tuple works. That's all from this session. 18. Tuple len and list: Hi there, Welcome to this session. I have this tuple here. And to get the length of this tuple, what I will do is I will call the length function. So to call that, I will write LEN and then in drone brackets, I will put the name of my tuple. So this will actually give me the length of might've bought when I would run this. As you can see in the output, it's a seven. And if I add an element to the initialization of this tuple, let's say 900. So what I get is it in the output, I can simply convert this double into a list by calling the list function here. So I will call the list function instead of length. So what I will get in the output is a list. So my tuple is converted into a list by this list function. So that's all from this session. 19. Mutable objects in a Tuple: Tuples are immutable, but they can have mutable objects. For example, if at the first index I put this list there. So list is basically mutable. We can add values to it, we can change. So now when I run this, as you can see in the output, we have a tuple that has mutable object. I can simply change the values, abandon, extend my list inside there. So how to do that? I will write the name of my tuple and then on the index where my mutable object is for resemble it's on 0 index, so I will write 0. So now by writing this, I get access to this list which I have here at 0 index. Now I can call different functions there, like append. Append will actually add some value. For example, if I say 57 now it will add to my list. And when I print the tuple, as you can see in the output, the value is added in my mutable object. Similarly, I can apply other functions here as well. And if this mutable object is at some other index instead of 0, Eigen simply assess that as well. So for example, it's here on the one index, whatever, on the two index. So I will write two here because on 0 we have this on one, this and then on to we have this one. So now simply when I run this again, as you can see, the value is added there. So by writing this, I get assessed to that element and then I can apply functions there. So that's all from this session. 20. Functions Introduction: Hi there. In this session we will learn about functions. Function is basically a block of code that processes something. It can also take an input and give us some output. For example, if we have a sum function, it can take some input and process it by adding them and give us some output. So function in biotin is defined by adding a keyword D-E-F, which indicates that it is going to be a function followed by the name of the function that we want to give. And then in the body we can define what block of code will be there in that function. So let's jump into code editor to understand it better. 21. Functions in Code: Hi there. In this session we will make function. So to define a function, first of all, we write a key, but DEF that specifies that this is going to be a function and then it is followed by the name of the function. For example, I want to make some function that will add some values, so I will name it some, and then it will be followed by two round brackets. In these breakers, I can give number of arguments to this function. So arguments are input to any function. So whatever I give here will be the input to this sum function. And let's say I give a and B, so they are separated by comma. And after that, I have to add this column sign. And then I can define the body of this function with proper indentation. So it will be, there will be some indentation from this function where we are defining it. And so it cannot be like this. I cannot add four here. So it should be with some space indentation. And then what I can do is I will just simply add these two values and store it in variable c. So a plus B, what I'm doing here is I'm storing a plus B and C and then I will return c. So this return keyword returns as the output of this function. So input goes here, the named arguments and return type goes at the end when it started, when it has completely processed everything. This return statement can be in-between as well, somewhere in the body, but usually it is at the end because we want to process something and then send what we have output. So now I will try to call this function. So I will go here and write the name of function. Now, simply, we can call functions by writing their names. So we have the sum function where it indentation shows me that it will take two arguments, let say 10 and do any. So what it will do is it will add these two arguments which I have sent here, the C variable and then return a C. So I can catch that variable here in some other variable. So for example, I say value. So this sum function will process these arguments and store the result in this value. And then I can simply print this value. So print is also an another function provided to us. As you can see, it has these two round brackets there in visually can give any arguments. What this brain function does is it brings on screen anything given as the argument. So I will give this value as the argument. And what it will do is it will print out in the output. So I will run this, as you can see, it printed 30 in the output. So this sum function process these values. So I can also have no Eigen that without storing these result of this a plus b and c, I can simply also return it by adding it here. So that will also work simply. I'm, what I'm doing here is without getting them in some variable, I'm directly adding the expression here after it done. And then I will get that in value and it will print that or simply I can also do that, that I don't get it in any other variable. I simply put this in print statement. So what print statement will do is it will print the result we get from this sum function. So when I will run this, as you can see, it worked again. So we can give any number of arguments in our function, or we can also simply give no arguments in our function. So now our function sum has no arguments or will commend this line here. And what we can do here is we can just simply print something inside this function without returning anytime. So I will say print my name. So if I don't call this function anywhere, this will not work. So if I run this, as you can see, there is nothing in output. I have to call this function explicitly for it to work. So what I will do here is I will call this function sum again. And we will see in the output, as you can see it printed home sign the output. So this function takes no arguments and returns us nothing but its body perform something that is printing my name, I'm humps on screen. So this is how function works and we can have different functions. So function is basically specific to some particular functionality. As you see, the sum function will add something so named should specify that what this function going to do that is not necessary that it name specifies dad, but it will be a good practice that the name of function specifies what it is going to do. For example, if there is a this is a function that is Brent in my name, it should not be some because it is adding nothing. So I will say print my name, print my name. So this should be the name of this function. And similarly, when I put it here, as you can see, it performed the same thing. So function name can be anything that we want. It is not specific to anything. We can name it as our function is performing. So that's all from this session. 22. Nested Functions: Welcome to this session. Functions in Python are first-class objects, which means that they can be nested inside other functions and they can also be passed in as arguments to other functions. We will learn about objects in our object-oriented programming section. In this session, I will show you some example that how we can have nested function. So I will define a function and I will name it outer function. So what it will do is it will simply brand on screen that, hey, I am outer function. And then I will have a nested function so I can define another function that I will name inner function. And what it will say Is it will say, Hi, I'm inner function, so I will just bring that here. And hey, I am nested. Function OPIA, nested or enter. Okay, we have this function here. Now, when I will call this outer function, this function will not be executed because we have not called this function anywhere. So, well here I will write outer function. And what it will do is it will only print this, hey, I am outer function. So as you can see, it says, Hey, I'm outer function. Now, when this function will be called, we can explicitly call that function inside the body of this function. And I can see in our function. So when I will run this, as you can see, my inner nested function has also been called. So this inner function can only be called inside this outer function because it scope is only inside this function. If I will try to call this function. Here, it will show me an error here, as you can see, unresolved reference in our function when I will run it, it will show me an error here that it says Name error. Inner function is not defined because the scope of this function is only inside this outer function, because we have defined it inside this function. And this outer function is scope is here. We are calling it because it is not nested inside any other function there. So that's all from this session. 23. Argument Types Explanation: Welcome. There can be different type of arguments that we can boss to any function that can be integer, float, string, dictionary, double, or even in another function as well. And we can also send key word documents. They are special where we define a very able and put it equal to some value. So keyword arguments are always the last values that we can pass in as an argument. They are followed by all other arguments. So we have to be careful about this, that keyword arguments are lost that with supply. So this can be divided into two types of arguments. The first one is positional argument, which covers all of these. And the second one is keyword argument. 24. Positional Arguments: Hi there. In this session I will show you how to pause positional arguments to a function. So I will go ahead and make a function here. I will name it function and I will put in an argument. So I will call it argument one. And what it will do is it will print whatever value we have an argument one. So all good. Now what I will do is I will call this function by writing its name. So I have to send in one argument. Now it depends upon me that what type of argument I send there. If I send an integer, this argument will become integer. If I send float, it will be flowed and if string then it will be strained. Or let's see with an example, first of all, I will send an integer. So as you can see in the output, it printed ten. Now if I send in some float. So as you can see, it's a float now. And if I change it to string, string1, okay, I will run this. And as you can see, it printed out their string 1. So the data type of this very, this argument depends upon what we send here. I can also send multiple arguments here. For example, if I have an argument, do I can name these anything, whatever I want. But for the sake of the example, I'm using T-S. So, okay, I can send in some list here, let say 1, 2, and it has a string. So I'm in the second argument, I'm sending a list eigenstates and different DIBL, things here, so I will run it. And now here as you can see it printed argument one, what I will do is I will also print argument two and run it again. As you can see, it printed string one, which was first argument and then the latest which was second argument. I can also and tuple here. So I will change it with a tuple and adding the value here. Okay? So as you can see, the first one printer is tuple and the next one is list. So these arguments can be of any type. They can even be a function as well. For example, if I have a function here, what it does, it, it simply prints my name. So this is for the sake of example only. So this is a function print my name, that can be anything. So I will add another argument here that say argument three. So what it will do is it will, I will send this function to dad, argument for dad. I will copy its name and printed here. So what I'm doing here is I'm sending this function to this variable. Now this variable whenever will be called it. We'll call this functionality of this function. So I don't have to add the round parentheses here, y. So if I add these own parentheses here, what it will mean is that first of all, call this function and then sent here the return value of this function. For example, if this function returns something, currently, it is not returning anytime, so it will be none value here. So if I return something, what it will do is it will send data value here, and this argument will become dad. For example, if this returns an integer, then this will become an integer. So to send this function completely, I want to send this function. So what I will do is I will remove these parentheses. And whenever I call this function now it will print Hamza. So I will just comment this line out and I will, what I will do, I will simply call this argument 3, and I will add these round parentheses here. Now because this is a function now, I will run this. And as you can see it printed Hamza. So whatever we will be having in this function will be printed. So I will add line to Hamza. Okay? Now, as you can see it called that function and printed these statements which are in that function. So now I will show you if I add parentheses here. Now what this means is now run this function and get the value out of there and send that to that argument 3. So currently we are not returning anything in this function. So what value you will get that as none. So on by default we will get none. Let's see. So we have an error because what we are doing here is NoneType object is not callable. As you can see, it says it's a NoneType object. And on a NoneType object we are calling it as a function that is not valid. So I will remove these parentheses, and I will try to print this argument. So argument 3 and I will remove it from here. So now what I'm doing is I'm printing the value of this argument 3 and data suppose to be none value because I'm not, okay, as you can see, it printed none here. So Hamza and Hamza I've done Remind is also printed because v call this function what it did. It printed these two statements and then returned us none. So argument three value was none there. So I will just simply add a return here and send something in the search on, for example, I send value 30. So now this none will be replaced by the value 30 because we have, in this argument three, we have 30. Now, that is an integer. As you can see, it is replaced with the value 30. So it returned the value 30 and which was passed to this argument three, and then it printed data. So I will just simply remove these print statements from here. And I will just run it again. And as you can see, it only simply prints 30, whatever we are returning in this function here. So if I change it back to the original way, we ready to move these parenthesis, and then I simply call this function argument three. Argument 3. Now what it will do is there will be, nothing will be printed on screen. Why? Because we send this function here in argument and then we call that function which returns 30, and we never use that value. We never printed that value. So I will run it. As you can see in the output, we have nothing because this function only executed and return the value, but we never printed that value. So we have, this is the way how we pass function to an argument. Or if we want to pass the value from that function. So this is how we send positional arguments to a function. In the next session, you will learn how to send keyword arguments to a function. So that's all from this session. 25. Keyword Arguments: Hi there. In this session I will show you how to pass keyword argument to a function. So I have a function here and it takes one argument. So I will call this function as keyword specified. There should be a key and then the value keyword. So I will first of all give a key and that key should be exactly the same name as of our argument here, which I have. So I will copy this. So this is the T and then the value. So I can add value that is integer or string or anything else. So first of all, I added and teacher here. So when I will run this, as you can see in the output, that integer is printed, so I will change it to a string, and I will run it again. And as you can see, strange is printed in the output, so we can give other values as well. But the point here is the P word value should be the last value. They can be multiple as well, but the positional values, the positional arguments should be behind this. So let's say we have an another argument here. That is argument. Do. So now, if I want to pause this keyword argument here and another positional argument as well too. What I will do is I will change it to argument two. So this becomes the last one. And in the argument one I can send another value, let's say 10. So this is an integer value that is positional argument, and then we have this keyword argument there. So I will run this. And as you can see it printed argument one day or when I will put it to, it will print argument to that is string. But if I change the position here, like if I make it the first argument, what it will do, it will crash. So let's run this by fixing this. Okay? So we have above positional argument follows keyword argument. So as you can see, the error, so we need to have these arguments placed. Well, we can also have multiple arguments there. I will just undo the changes I have done here, and we will add another keyword arguments. So let's say we have argument three there as well. So what I can do here is I can provide a keyword value for this one. Let's say do any or some kind of a list, 1020, okay, we are passing the list. So then I will run this, it will work fine. And when I print argument three here, it will print that as well. I can print all arguments as well. Are women one, argument 23. So when I will run this, it will print all values. So this one is the first, then second, and then the list which we have paused here. So this is the sequence in which we pass in the arguments, first one positional and then keyword. So that's all from this session. 26. Multiple Arguments: Hi there. In this session I will show you how to pass multiple arguments to a function without explicitly defining the number of arguments. So I will write an example here. If I have a sum function and it takes in two arguments, a and B, what I will do is I will print by adding these. So a plus B. Now I will call this function here. Pass some values. And as you can see, it printed 12. So what if I don't want to explicitly specify this number of arguments there? If I want to send three or four numbers that I want to add, I don't want to restrict it to two. So how I can do that for dad? I will write an asterisk sign and then a RGS. This a RGS is not restricted or is not a keyword that you need to use, It's your choice. But conventionally we use this for positional arguments. And what it will do is it will make a tuple of whatever we send in this function here. So I have 10, two, and let's see, I will add another argument three here. So what it will do, I will print archives for now. And as you can see, it printed the tuple then 23. And if I add an another value here, it will also add that to a tuple and print. So this args become a tuple. Know I can send any number of arguments to the sum function and simply I can add them to how I can add them. I will quickly write a for loop to iterate over this tuple. So I will say value in August. So every value in this arcs double I am. What I'm gonna do is I'm going to add that. How I can add that is I will make a variable here like total, total sum and I will initially put it equal to 0. So I will write total sum plus equals to value. So what this plus equals two does is it adds the left and right and store it in the left one. So it is equivalent to this if I write it though, Some plus value. So what it will do, it will add total sum and the value and update the value of total sum. So initially it will be 0, and here we will have 0 and then the first value that is ten, so it will store then, and then it will take the value 10 in this total sum and the next value of this value and update the value of total sum. So we can simplify it by writing plus equals to value. So now what I will do is I will return this total sum, return total sum, and I will get that value here. I can simply print that value here as well, or I can print it here. I will try to print it here. And okay, so whatever we get from the sum function, we will print it in dogs. So I will run this now. Okay, we have an error here. It says unindent does not match. So here we have an indentation problem. As you can see, there is a space here. So this return is a part of this sum function. So by adding this indentation, it, it, it goes it wrong. So I have to remove this indentation. Now as you can see this line here, this is a part of the sum function now, so I will run it again. So as you can see it printed 19 they are, Dad is the sum of all these. So I will just change it to now two arguments. So it printed 12 and then three, adding one, it printed 30. So this is how we pass in different positional arguments when we want to set them there. So I will just remove brain from here, and instead of returning that, I will just print it here. So it will give us the same result here. Okay, I will run this, as you can see, it printed 13. And I can also have like different type here. For example, if I give 2.2, that is a float value now, so as you can see, it added 15 to there. So this is how it works. Now we have sand in positional arguments. Similarly, we can also give keyword arguments for that I will add double asterisk for and then w, a, r, g scale WAR GIS data is for key word arguments. That is conventionally conventional way of doing that. You can name it anything. So I can pass in now another value. So I will just remove this spot here and I will try to print dogs. And then I will print the word ox. Okay? So I will send in, I will send some key word auxiliary as well. So I can say a equals to n0. So this a RGS would be a tuple and this would be a dictionary because we have E and values there. So I will run this. And as you can see in the output, we have additionally there with a key and a value 20. And I can now send an another value here as well. Let's say I call b and I will put it equal to some strain that is strain one. Okay, I will run it again, as you can see, and other key value has been added to our dictionary. So this is how we can send multiple arguments to a function without specifying them in here in the input section of that function. So this is a useful thing that we can apply. So that's all from this session. 27. Decorators Explanation: Hi there. In this session we will learn about decorators. Suppose we have a function that prints my name and I want to add some functionality to this function, but I don't want to change the body of this function. So I can do that by using decorators. Let's look at an example. I have this function print my name, that prints my name. And when I will call this function in the output, my name will be written. Suppose I want to add some greetings in my output as well. So how I can do that, the first way would be to add these print statements in my function body that will reflect that change in the output. But I don't want to update the body of my function. I want to keep it as it is. So here decorator comes in, I will make a decorator function and pause this function as an argument. And then inside I will make a wrapper function that will be a rapper or my dysfunction, where I will move these brain statement and then I can call my function in there and finally return the wrapper. So we will get into the details of how to do it in our next coding session. But for this session, we have to know that the decorator function takes in these two print commands and update our print my name function. Then I will add a add digit annotation over my function. So what it will do is now, whenever I call this function here, it will reflect these changes there. So the body of the function will not be changed, but we will add something to that function. So decorator is simply a wrapper over my function that add some functionality to my function. So let's jump into the code editor and write some code. 28. Decorators Code: Hi there. In this session we will learn about decorators. So let's write an example. If I have a function, let's say rent my name. So what it will do is it will print my name simply. So I will write comes up till right. Okay. So now I will call this function, print my name and I will run this. And as you can see, we have printed it in the output. Now, I want that there should be some greetings here as well. What I will do is I will add few more print statements. That is a salam alaykum, Good morning. And then allow is bye-bye greetings in Islam for peace and blessings. So I will just add these, so I will run this and they will be added here as you can see in the output. But what I want here is I don't want them to be in this function. I don't want to change the functionality of this function here. So what I want is I want to remove this and remove this and still want that to be printed. So what I can do is here decorator jumps in. So I will write a decorator function here, okay, I will define a function. I have named a decorator, but you can name it anything. It is not hard-coded that you need to specify it as decorators. You can add anything here. And then in the arguments I will give any function. So we will be passing a function to this decorator. So I will name it function again. You can name it anything as you want. And then inside of this decorator function, I will have an another function, dad will be a wrapper function. So first of all, I will write it and then I can explain. So I have named it wrapper. Again, you can name it anything. So this is not hard coded, so I'm making a wrapper function here. And inside of this function, I will call this function which I have boxed here. So I will write function and parenthesis of this function. And then finally, outside of this inner wrapper function, I will return this wrapper function here. So return wrapper and I will not add these round parentheses there, and I will explain it. So I will explain it in a while. So we have this wrapper function. What it is doing is they're just calling our function, which we are passing in there. And now I can add those greetings in here on top of this function. So what I will do is I will remove this bot here and I will add this to here. So what I'm doing here is I'm adding this print statement. Good more a salam alaykum, Good morning. And then calling this function. So this will do the functionality which we have in this function, and then this will bring, so we can add things before and after this function here. And now what I will do is I will add a decorator annotation on top of this function, which will tell us that this function is decorated. So at the rate, decorator, as our decorator function name is decorators. So I have added an annotation of decorator. If I change it to something else like decorator one, I will have to add decorator one so you can name it anything. But this name should be similar. So now this function knows that it has been decorated and it will go into this function. I will just print this, I will just run this and then I can explain. As you can see, we are getting the same output as we were getting before, but we have not even change the functionality of this function. So it's untouched, but the functionality is changed because we're only calling this function print my name. We are not doing anything else. And this print my name function has this print statement bus, but it functionality has been modified by this decorator function which we have here. So decorator function is used to add functionality or that function. So this function, brand My name is wrapped by our decorator function. So let's again have a look how it has been done. What I'm doing here is making the decorator function where I'm sending in this function, that is this one. And then we have a wrapper function. This function will wrapper over our dysfunction. So here we have this function and it has been wrapped with these two other print statements that we have here. We can have different things here that we want to perform before and after this function. And then finally, as we know that these functions in Python, we can have nested functions as well. So in this, what we are doing here is we're sending this wrapper function in a return. So when we send this wrapper function and then return to this will be applied to this function by this, add the date decorator annotation which we have. There. So we don't have to provide round brackets here. What it will do is it will, this will fail because it will run this function then. So in the output, as you can see, we are getting error. Nonetype object is not callable and then some random results there. So we need not to pause these round brackets. Similarly, the name of this function which will pass that function. So what we're doing with this additive decorator is equal to what I'm gonna do now. So what I will do, I will just say print my name. This function, put it equal to call my decorator function and then pass in this sprint mind Name function there without the parentheses because we want to send this function. So what we were doing before is equivalent to this one. By adding debt at direct decorator annotation, we are simply replacing this line. So now this part here is clear that why we are sending the wrapper function without the loan parentheses, because we want to apply this function to this function. So I'm saying print my name function is equals to call the decorator function and print my name function which I have. And what it will return me is the wrapper function. So now this wrapper function, as we see, is modified, has some additional details. And when this function returns us that wrapper function that will be applied to dysfunction print my name. And now whenever I will call it with their own parentheses, it will execute the functionality of that function. So I will run this. And as you can see, it worked fine with this statement as well. So just to replace this, this line, I will just add an ad, the rate annotation on top of that. It seems to me that it's more easier and more good way of doing it, which does the same job as that line which we have just removed. So this is how decorator function works. Now what if we have some arguments here as well? Let's see, I'm sending an argument name here that will print on Lee the name. I'm not hard-coding it so I can send any name here to this function I will add, let's say John. So now how we can handle this in this decorator function currently this will not work properly. So as you can see, it says it takes 0 positional arguments, but one was given. So our decorator function needs to be updated. And what we have to do, we will add a RGS for positional arguments in a wrapper function here. And similarly in our function call here, because our function has that argument. So now it can accept any number of arguments that we can give as we have learned before about this asterisk, args, which can take any number of arguments there. So VM, we just need to specify dad and now it will start working there. As you can see now the name has been changed to John. So I will send Peter here and the name will be changed to Peter. So that is how we handle positional arguments. And if we want to handle keyword arguments, we can just simply add double asterisk here with k, WAR GS. So again, this can be anything you can name these thing, anything, olives and KW hours. And I will add this to in my function call as well here. So, okay, we have it here now and now I can send key what arguments as well. But it will also work if I don't send any argument key, what are women? So I will run it. As you can see, it works fine and I can try sending the keyword argument here. I can, I have to first of all, added in the definition of my function too, I'm saying here we will be getting some argument. So I can name it anything. I have named it argument for just this example, and then I will put it equal to some value, let's say string, okay, I can say keyword argument. Okay, now we are sending a keyword argument has well to this print my name function. And what I will do is I will also print data here so that we can see a result of that. And I will run this. As you can see, it also printed the T word argument there. So I can change the value of this function as well. Do anything, for example, an integer here. So what it will do, it will print that value as it is. So now we have that keyword argument there as well. So if I define this spot here and don't send any arguments, it will work for that as well. So I can remove these arguments. And I will then have to also comment this out or remove this and print something like anything for just to have somebody on this function, body of function. Ok, and now I can remove this here as well, just to show you that these things, adding these args and kw args does not hard-coded to be that it needs to have some value. It can work without values as well. So I will run it. And as you can see, it worked without sending any values there. So we can add these, add these tenancy or like this. So this is how decorator function works. So that's all from this session. 29. Set: In this session, we will learn about set. Set is a collection of elements without any duplicate values. And sets are unordered. That is, there is no sequence. As it was enlists, we had index but inserts. We have no sequence. So they are unordered. Here we have a set that contains three elements. That is apple, orange, and men who? In this example, in the first example where we have apple, orange, apple beer for elements that is not a set because Apple repeated twice. So the second example where we have three elements, apple, orange, and peer, it's a set because there are no duplicate values. So the point to remember here about set is there are no duplicate values insert and sets are unordered. There is no sequence offset. Let's write some coding example of sets. Okay, let's start by writing our first example to create a set V required keyword set. As you can see, then Delhi sense is telling us about set. So we will just select it. And then we will add to round brackets indicating that it's a function. So now we can give an argument. Let's suppose we give a string here. Abc set treats every character in a string as a separate element. For example, in this string, ABC set will treat a as a separate element, B as a separate element, and see as a separate element. So the result of this set will be containing three elements. First one will be a, second one will be B, and turbine will be seen. Now to store the result of this set, we will create a variable and store the output offset in debt. So I will name that variable first set. So I will just quickly print the variable for certain. We will see the output print first set. As you can see in the output, it printed a set with three elements, b, a, and c. And we know that sets are unordered, that there is no sequence inset, so it is without sequence. Now if I add a duplicate value in this set, Let's see. In ABC, I will add another two a's. So now I will run this code and see the output. As you can see, the output is still the same because it removes the duplicate values. This is the feature of set that there are no duplicate values. The set scan can be used to remove the duplicate values from large lists or strings. Now just right now we will write in another example. We will name it the second set, which is equal to set. And now we will give a list as an argument. So to make a list, we will add do brackets. First element will be Apple. Second is orange, turd is banana. Okay, let's print the second sector. As you can see, the output is a set with three elements, banana, apple, and orange. And it is unordered. It placed banana or D first place epilepsy segment and orange at the third. So do not follow any sequence. Now let's add a duplicate value in this list and see the output. So the element orange is repeated in the list. So now I will run it. And as you can see, it didn't include it. The second orange and the sequence of list has changed. Apple is on the first index, bananas on the second, and oranges on the third. Because set do not follow any indexes, is random. That's all for this session. In the next session, we will learn about operations on set. 30. Loops Introduction: Loops are used when we want to repeatedly run a specific part of code over and over again. For example, if we want to print from one to ten on the screen, the basic way of doing it is using 10 print commands. So we have to write print command 10 times to achieve this. But instead of doing this, we can simplify it by using loops. Basically, there are two types of loops for loop and while loop. We will get into depth of these loops in our upcoming videos. 31. For Loop: In this session, we will learn about for loop. For loop starts with the keyword for followed by variable. This can be named anything because this is a variable that will contain a single value for each iteration of for loop. Next we have range. The most easy way often in for loop that how many times it should run is by using the range function. We have already learned about brain function in previous lessons. Range will return a list that will contain series of numbers. And for each number, loop will execute the body. Range specifies that harmony dying loop should iterate through the body or for loop. The body of nucleon be a single statement or it can be a bunch of statements. Let's look at an example. In this example we want five numbers from 0 to four to be printed on the screen. So we specify a range of five, which will give us a list of numbers from 0 to four. And for every number in list, loop will execute its body. So what it will do here is fostering function will generate a list of five elements from 0 to four. For the first iteration of loop. First value of list, that is 0, will be inserted in variable value. And then it will be printed by print command in the body of loop. Then in the second iteration of loop, second value of list, that is one, will be inserted in the variable value and it will be printed. Similarly in the third iteration of loop. Third value of list that is due will be inserted in variable value and it will be printed on screen. This loop will continue for all the values of list. As we can see in the output. Last value printed is four, which is the last value of list. We got from the range function. If you figured out why five is not included and output, you are smart. Because we know that in brain function, upper limit is not included. In our case, it is five, so it is not included and loop ends at value four. So our print command executed five times for each value of list from 0 to four. Let's look at another example. In this example we have specified range from negative two to positive three. As you can see in the output debt loop executed five times 4 value from negative two to positive two. We can also have custom lists instead of list generated by range function. As you can see in this example, we have a list of fruits that contains three elements, apple, orange, and mango. And we have given this list two for loop to iterate through every element in fruits list. You can see in the outward debt FOR loop executed three times for every element of list and printed it. Now let's jump into code editor and write some code. 32. For Loops Code: Okay, let's start with an example one. In this example I will make a list and then we will iterate through every element of that list using a for loop. So I will create a list. I've named fruit. It will contain some elements like mango, apple, and orange. So let's make a for loop. For value. In our list of fruits. Make it s. Okay. We will print every value, present value. Let's run it quickly and see the output. As you can see in the output, it printed all of the elements of the list fruit, that is mango, apple, and orange. So what FOR loop did it iterated through every element of this Fruits list. Firstly, took mangle as a value, then printed the value, then it took Apple as a value and printed that value. And then finally to oranges value and printed that value. So it's simple and easy. It just iterated through every value of that list. Let's move to an, another example. In this example I will. So for value in range, let's say starting from one, ending at five, it will iterate through 1234, not including five, because as we know in range function, upper limit is never included. But the lower limit is included. So I will just firstly print all the values. And we will see the output. As you can see in the output it printed from one to four. So range gives us a sequence between 14. Now I can quickly change the range. I will just make the lower limit to minus 2 and keep the upper limit 23. So it will print from minus two to positive two. Let's see the output. It printed minus two minus 1012. Here you can see in the output. We can also give increment in range function as you remember from our previous lecture. So I will just add an incrementer of two. So it will now just, instead of increment of one, it will give an increment of two. Let's see the output. As you can see, first value is minus 2. Second with the increment of two, it is 0 third with the increment of two, it printed too. So you can play around with this for loop by changing the values. And it's simply the range function simply gives us a sequence between what parameters we give to this function. Let's move to an another example. In this example, I will make a string and then iterate through every character of that string using a for loop. Let's see how it is done. I have a string name, name, and I can give a value. For example, John. As you know, as you remember from our previous lecture, that string is a sequence that every character is on some particular index. For example, J here in John is on 0, index edges on one. I will just print all the values for value in name. Print, print value. So let's see the output. As you can see in the output window, it printed J, H, O, and N. It took this name string as a sequence. Because we know this is the characteristics of a string that every character in a string is on a particular index. 33. Task Tables App: Your task for the practice of for loop is this. Write a program that will ask the user to enter a number. Then you will bring the table of that number. Use for loop. The flow of your program will go like this. You will ask the user to enter a number. Suppose he enters two. So you will bring to the table of to give it a try. Solution is provided in the next video. 34. Tables Task Solution: Welcome to the solution of task. If you have already completed that task, that's great. If not, we will discuss the solution here. Let's start. So das was that you have to rent a table by asking user the number. So for dad, I will first of all ask the user for a number. We know that we use input command here. Then I will write here and turn. And whatever number is user enters, we will store it in a variable. Let's say number is the number variable. So I will, now I will create a for loop. As we know we want then entries from one to 10 for value in, we can use range function in this. So we want to start from one. So I will give lower limit of one and we want to end on then. So as we know, we have to give one incremented digital, so it will be 11 here. So range will give us a list from one to 10. Now, we will multiply this number as we know in value, we will get the list elements. So first there will be the first element, then so on. So I will just make another variable, I will name it and multiply, which will be equal to value into number. So what we are doing here is we're multiplying number the user entered. That is a debit number with the value each time. So it will give us the solution. As we know, number here ridden by the user is a string. So there is a function to convert this to an integer because here we can, we're multiplying value that is an integer with a number. That should also be an integer. Currently it's a string because input will return us a string. So I will, I will falsely change this number to integer. For that, we can use a built-in function that is called int. And then I have to add these two long brackets here. So now it will convert this number that was previously string to an integer, and then we will multiply it with the value that is already an integer because we know range when you're done us a list of integers. In the next line, we will just make the structure of a table the each line of our table. So I will name another variable that is nine. Now I will make a line here, line of the table by joining different strengths together. So first we need in all the guesses. First, value will be number. Because if the user entered two, it should be due into one is equals to like this, the pattern should be like this. So I will say number concatenated with multiply sign. So I will give spaces behind and after, so that there is a good presentation. Then I will concatenate with value. So value will be changing every day. So like if we enter due, it's due into one, then doing doo, doo, doo into three and so on. So value, as you know, is in for loops, so it will change than we should have an equal to sign. Then I will concat it with the solution. As we know at the end, we should have the solution that is stored in a multiply variable because you multiplied here and it is stored in multiple variables. So I will just add it. Multiply. Here. We know that plus sign is used to can get concatenating strings. Here we know that plus sign is used to can get strings. But in this line we have few numbers. Like number is an integer and it's not a strain. Multiply is also an integer and it's not a string. Value is also an integer. It's not a string. So v, by using the plus sign, we can only get them get strings. So I have to convert these integers into string. So we can again use a built-in function, SDR and round brackets. So anything given inside these do long records of SDR will be converted into a string. So now we are saying correct, this number which was previously integer, is converted into strain, then concatenated with this cross sign and then value. Similarly, I will repeat string for this value as well. And I went for this as well. Now it makes sense because we are connecting strings rather than numbers. So this is a string, this is also a string and these all are strings. So now I will just print each line. So as the loop will continue every time new line will be printed with the values changed. So let's quickly run this and see our output. It is asking for a number. I can give two. As you can see it printed. The complete table, do into 1 is 2. Doing to do is fall. Until then. If you want the 20 entries to be printed, I will just simply have to change the range here, and it will bring other lines as well. I will just add a colon sign here to just improve the quality. So now I will try giving it an another number. Let's say I gave it five. It printed the table of five. If, if I want 20 and Greece rather than den, so I will just change it to range limit to 21. So now the range limit is starting from one and ending at 20. So let's see. Under number, you can give any numbers was I give them. So as you can see, it printed 20 entries. So distinguished simpler with for loop. As you can see, we can do a lot more task using loops rather than writing simple gold lines. So this is the benefit of for loop. You can find other benefit as well because this is a very useful component and it is used in many languages. So that's all for this session. Let's move to next session. 35. While: In this session we will learn about while loop. While loop is another form of loop. While loop starts with the keyword while, followed by condition that needs to be true for while loop to execute the body of the loop. So as long as condition is true, loop will continue. And as soon as condition becomes false, while loop will stop. For every iteration. While loop will check the condition. And when it becomes false, it will stop. Condition here can be anything. Here we have some examples to understand the nature of condition. For example, we can have a condition that variable value less than 10. It means that execute while loop until value or variable is less than 10. And as soon as well your variables becomes 10 or greater than. Then stop executing glue. In second example, we say that execute while loop as long as value or variable is not equal to 200 nine. So if value of variable will become 09, while loop will stop its execution. And if it is any other value except to 0, 9, loop will continue. We can also use multiple conditions using AND and OR operators. Similarly as we did in if and else. If we use AND operator, then both the conditions need to be satisfied. For while loop will continue execution. If any single or both conditions or failed, then while loop will stop. And in case of OR operator, if only one condition is true or both conditions are true, loop will continue execution, and execution of loop will only stop if both conditions are false. Now let's start some coding examples. Let's write our first coding example of while loop. I will create a variable. I, and I will assign a value 0 to it. You can name this variable anything. I use the most commonly used variable in loops. So I'm using AI, but you can name it of your own choice. So I will create a while loop by keyword vial, as you can see in Delhi senses telling us about, right? So then to round brackets inside of these two long records, I have to provide the condition. So here we can provide any conditions. I will give a condition that I is less than five. And a colon sign. In the body of the while loop. I will print i, brent i. And what I will do more here is I will increase the value of i every time. So I will say I equals to I plus 1. So now every time the loop body will execute, IE will be increased one time. So the value of I will have an increment of one. So let's see the output. As you can see in the output it printed from 0 to four. So what it did here, initially the value of r equals 0 for the first iteration of the while loop. The condition that whether I is less than five, the condition was true. So it entered into the body of the loop. It printed the eye, which was 0 initially. Then in the next line, it incremented i with one. So now the, now contains the value one. Now next time, when the while loop executed eject for the condition, now current value of I is one and it is less than five. So the condition was again true. So it printed I and incremented by one. Similarly for the third diamond again, check the condition. Now I was due and condition was still true. So it printed I and incremented it by one. So for the 4 fourth value, it was seen. And when I became five, the condition became false here. I was equal to five. So while didn't execute it, and it stopped on 4. If I change the condition here that I is less than 10. So let's see the output. As you can see in the output, it printed from 0 to nine. So this is the benefit of while loop that we can do more things and less lines of code. If I change the value of variable from 0 to ten. Now the while loop will not execute even for a single time. So let's see the output. As you can see, there is nothing in the output because the condition field for the first time, I was 10 and it was not less than 10. So the condition failed and it didn't execute it the body of the while loop. So we can give any of the conditions of our choice in while loop. We can also give multiple condition here. So I will just make an another variable. I will call it name and early string, let's say Smith. So I will just add an operator and check the condition for name as well, named W equals two. I say if it is, if it is met, then you have to execute the body. So now we have used the and operator. So both of the conditions on the left and the right side of the and operator needs to be true for the execution of the while loop. If anyone condition fails, while will not execute its body. So I will change the 9p21 and name is met. So I will just execute the code here. And as you can see in the output window, it executed from one to nine. Now if I change the name, if I changed or I misspelled it, I will add an another edge at the end here. So the second condition, condition become wrong, it become false so the loop will not execute. Let's see. As you can see in the output, it didn't print anything because the second condition failed. But if I change this AND operator to all operator, now what ALL operator means is if any of the condition is true, you have to execute the body. Now we have I is less than 10. Dad is true, but name is equals to Smith. That is not true. But the loop will execute because of all operator. So we will just quickly run it. As you can see, Lou executed for all the values. You can try changing these conditions and play around with while loop. So you will learn it better. Now for the sake of fun, I will just tell you one thing that we can also go into an infinity loop. If we write while one. So while one means go into an infinity loop, this loop will never stop. So I will just print some time here and I will write fun. So let's run this. As you can see, it keeps on branding string fun. So that's all for this session. Let's move to our next session. 36. Conditionals Intoduction: In this session, we will learn about If and Else clause and Conditional Flow. Many dimes and gold we have to deal with conditions. Conditions, simply del that. If it is true, execute this code and do the stars. And if condition is false, execute other code. To check the condition we use if and else clause. If keyword is followed by condition. If the condition is true, it executes the body of it. And if it is false, is simply executes the body of Else. Suppose we have two variables, x and y. X is assigned value 20 and y is assigned value 30. Now we want to check whether x is greater or smaller than Y. So we use if else here. In if laws, we have applied a condition that check whether x is greater than y. If it is true, print x is greater than y. And if the condition is false, execute the else clause and print x is smaller than y. There are many conditions that you can apply greater than, less than. To check if values are equal, we use double equals sign. And to check if values are not equal, we use exclamation followed by equal sign. Now, let's write some code to get better understanding of conditionals. In this example of if and else, I will create two variables. Then we will check whether a variable 1 is greater than variable two by using If and Else clause. So let's make a variable x and assign it a value 20. Let's make another variable y and assign value 32 it. Now I will write IF clause and a condition whether f is greater than y colon. And then I will print x is greater than y. And in the other case, if it is less than y, then else print x is less than y. Let's see the output. As you can see in the output it says x is less than y, because we know 20 is less than 30. So it didn't execute it the if part here, because x was less than Y. Instead, it executed the else part, which says x is less than y and printed the statement. Now let's swap the values of these variables. I will stall 30 in X and 20 invite. And now it should print x is greater than y. Let's see the output. As you can see in the output, the output has changed. Now it says x is greater than y because the values have been changed. So we can use these if and else conditions. If we want some code to be executed after a certain condition is fulfilled, we will write that code here in if Bart and other board in the else part. Remember that indentation is very important here. In addition means the body of if will be placed after some space, which indicates that it is a part of if. Now if I remove the space from here. Now as you can see, if and print out on the same line and it started giving error indent expected. You can see the warning. It is saying indent expected. What it means, it requires us to place a space here to indicate that it's a body of if. And similarly, if an else case, I will place the print statement in the same line or else it will again say error. So I have to give some space after dad, which will indicate that it's a body of else. So in Python, indentation is followed in every case where we have a body of any certain chord. In case of if else, we have the body of the if and body off as as, as you can see, x and y are not a part of if and else. So they can be on the same line of if and else. They need not to have any space behind them. But this print statement is a part of if gloss. So it has to have some space after if gloss. And this branch statement is a part of glass. So it needs to have some space behind it. This indentation is followed in Python. That's all for this session, you can try making different variables and applying different else clause on that. 37. Elif: Many times there is a requirement to check multiple conditions beside only if and else. For that, we use and another clause. Which means else if. By using this command, we can provide multiple conditions. As you can see in this example, where we have two variables, x and y. And we want to check whether x is greater than y or it is less than Y, or it is equals to Y. So to achieve this, we will use LF command. In the first condition, we are checking whether x is greater than y by using IF keyword. The next, instead of using else, we are using L if rejects, whether x is less than y. And in the third condition, we are again using lf to check whether x is equals to Y. We can use LLF as many times as we want. Now let's write some code. In this example of L If we can choose our goal of if and else, where we created two variables, x and y. And check whether x is greater than y or it is less than y. Now I will replace this else with if, as we know, LF require condition. So we will give a condition if x is less than y. And we can add a third condition as well, which will check whether x is equals to y. To check if x is equals to y, we use double equals to sine. So we will print in this case, that x is equals to y. X is equals to Y. So now let's run it. It says x is greater than y, which is correct. It, it executed the if part here, which says x is greater than y, left the other two LF parts. Now we will just made these values equal and we will see the output. So X contains 20, y also contains 20. So now it should execute this last part which says x is equals to y. Let's see. Yes, Is, it says x is equals to Y. So it executed the last part and left these first two parts. So what it does here, it's check the condition of if, if x is greater than y, it was not correct. So it left it. Then eject the condition. If x is less than y, it was also not correct. And move to the next condition. Then it checked dead whether x is W equals to y. And it was correct. So it open-ended x is equals to Y. We can also use if elif and else together. What if I remove this loss condition? And Jews else here? It will also work because in this case we have only three condition. That x can be greater than y, or it can be less than Y, or that there is only a third case, that x is equals to y. So if these two conditions are not true, it will move, move to the else part, which is the default part. Because we know x is not greater than y or it is not less than y, the only gets left behind is that it is equals to Y. So let's run this code. As you can see, output is same. It says x is equals to Y. So it executed the else part. The benefit of doing this is there will be a default case and else will always be executed if other two failed. But if we have L If here and the condition failed, this it will not execute the body. We can also apply if and else on strings. So let's quickly write an example of string. I will make a variable name, which is equals two, comes out. And I will write a welcome message if my name is equals to omega. So I will write if name is W equals to Brent. Welcome Humphrey. And I will have an else here, which will brand unknown. So I will run this code and we will see the output. As you can see it compared the string Hamza with the variable name. And it, it was seemed so it printed welcome Hamza. Now if I change the name, I changed the name to Alex. Now it should print unknown. As you can see in the output it printed unknown. It applied the condition on string as well. So we can have different variables and try different conditions on them using if and else. You can write different, multiple examples of these by your own. So this will make your skill stronger. That's all for this session. Let's move to the next session. 38. File Handling Introduction: Hi there. In this session we will learn about file handling. So files are used to store data that can be text, binary, or any other form, and it's permanently stored in that file. So the data in file does not disappears when are program terminates, It's a permanent storage where we can store data and we can apply multiple operations on these files. The function used in Python to open files is named opened and it takes two arguments. The first one is filename in which we have to specify the name of file which we want to open. And the second one is mode in which we want to open that file. That is, we want to open it in read mode or write mode. Let's have a look. R is used for opening new file in read mode, and w is used for writing a for appending an r plus, both reading and writing. So our file has data. Let's take an example here where our file has file handling in it. So every character in a file is asked some particular index. And when we open a file in read mode, our pointer is at 0 index datas and the starting of the file. And sports we call it function read and boss and argument for. So what it will do is it will read the first four characters from that file. And in this case it will be file here. And the pointer will be pointing to the very next index. And suppose we again call read function with the argument five. So what it will do is it will keep on moving from where the pointer is, and it will move to index nine, and it will give us a whitespace and HA, AND so five characters and it consider whitespace to be taking a specific space. It's not like it's on a particular index. So in this case it's an index four. And now if you want to open a file in write mode, anything that is in that file will be removed and the pointer will be on the 0 index. Now we can write in this file, so we have to be very careful the right mode because it deletes all the data in our file. And if you want to open a file, and we do not want that it can contention go away. So we will open it in append mode. So in append mode, the pointer is on the end of the file. Now let's jump into code editor and write some code. 39. Read File: Hi there. In this session we will learn file handling. And first of all, I will make a file and then we will read content of that file. So I will add a new file. Let's say I will name it file dot TXT. So we got the file here. Now I will add some content here like hi there. Let's learn file handling. Okay, now I can open this file in my script, so I will use the open function, and as you can see it except some arguments there. I will add the name of this file because it's in my same directory. I need not to give the complete address. I will write file.txt. As you can see, intellisense shows me the name of file. So it's, this file is not in the same directory as our dot py file, then we have to give the complete address here, like whatever it is, the complete address. Now by default, if I do not specify any mode here, it will be in read mode. I will specify here to show you, to demonstrate how it works. So R is for read mode. Now, I can get the object of this file in any, in any variable I have, I can name it file. So what I'm doing here is I'm opening this file in read mode and getting the object in this file variable. So now I can apply different operations on this. So what I will do here is I will read the file and then I will print it in the output. So I will save file dot read. As you can see, it gives us multiple functions for reading. We will start with the read function. What this function will do is it will read all the contents of this file. So what I will do here is I will print it. So printing the complete file, as you can see in the output, it says high they are. Let's learn file handling. Now let's change something here. I will say a new line. And I will run this again. You can see new line is added there, so it reads the complete file here. Now there is an another function read line. What it will do is simply it will read any single line starting from the first pointer if we read the first line there. So as you can see it printed hi there. So if I run this function two times, it will read two lines. So as you can see, hi there and then let's learn File Handling. So calling this function readline first-time, printed this one, and then the pointer after reading the first line was there on next line. So it moves the pointer there. It didn't stayed on the first line. So after filed artery calling readline again, it printed second line and so on. If I call it multiple times, I can read other lines. Now there, I can specify argument in this function as well, like how many characters from deadline I want to read. So for example, if I say our, I want to read two characters. What it will do is it will print hi. And then if it will, I will call it again. And I will say, let's read four characters. What it has done here is it has read the next four characters in that file. That is one whitespace and then THE, so it keeps on moving that pointer when we call these functions. Now, let's explore and another function that is read lines. So what this function does is it will read lines and return a list. Now, we will get a list here. I will run this and as you can see, it's a list here which has three elements. The first one is there, hi there with the slash and for the new line. And then let us learn file handling with a slash and then a new line. And then finally the new line which we have, they are written in our file. So what it does, it returns us a list. If I print the count of this, it will be three. So let's print the length. As you can see, it says three because we have three lines in our file. If I will add a new line here, count will increase to four. As you can see, count increase to four. So this is how we read our file. By default, this R is already did. And if I add an another tier, it will mean in a text mode as we have text in our file. So this RT is by default there. But there are another modes like binary, where I can open a file in a binary mode as well, depending upon the data which we have in our file. So Dad, I have to explicitly define here that I want to open it in binary. So by default it is our t that is read file in text mode. So if I will remove this part here, it will still work. As you can see, it still works here. I will remove this land function here, and I will run it again. And as you can see it return me the list. So that thing was by default there. And if I want to add any other mode that is writing appending, I have to explicitly define that here in this mode part here. So that's all from this session. 40. Try Except Python: Hi there, Welcome to this session. When we are working with files, we should always put them in try except block because anything can go wrong at any point. For example, I have this file.txt here. When I run it, what it does, it, it reads this file. So what if I don't have this file here? Let's, I will change the file name. Let's say I will add a to this file name. Now this filename is wrong. When I will run this program, as you can see, it shows me a crazed bag. It says no such file or directory. So it, it gives me an error here. Now when a user is using it, it's a very, it gives a very bad impression to a user who is using our program. So what we have to do here is we have to put this in a try except block. Now, we can properly handle this. So I will take care of indentation here and then accept. Okay, now I can properly handle this by printing the user or saying something went wrong. Ok. Now when I run this, I can see it says something went wrong here and properly handled this. So it does not break our program, but it goes into this except block and print them messy. We can be more specific in this message as well. By getting our exception here and printing data exception instead of our custom message. So what I will do here, I will run it. And you can see it says no such file or directory, file a dot TXT. And if I remove this ear from here, now it's a valid file that we have here. And I will run it. And as you can see, it printed that file. So putting our file and try except block is very important. 41. With and Close: Hi there. It's very important to close the file when we are done reading the file or applying operations on that file so that all the resources allocated to debt file or released. How we can do that is by calling the close function, I will write it here. Okay, so by calling disclose function, it will release all the resources that are allocated to this file. Python also runs the garbage collector that will automatically do that. But we do not want to wait for dad garbage collector to run and release those resources because that can be a bit late as well or any particular time that Python runs it automatically. So what we wanna do here is V1 and close the file and release all the resources attached to this file right after we're done, operate in this file. So there is an another way of doing it as well. We need not to call this file dot close function explicitly because we might frog forget this line of code in any bot. That is the possibility that we forget this. So simpler way of doing it is with Key Vault. With the keyword named with I will add here, I will change a bit for Mateer with open file. Now, I will specify the name here as file. Now what it will do here is in this width block, I will do all the operations that are applied to our file. And this bid operator will automatically release all the resources which are given to this file. So we need not to call that close function explicitly. This vid will handle all those things for us. So this is a better way of doing it in which there is less possibility of error. And this will handle all the things here. Now we have to put all our operations inside this width block so that when these operations are completed, automatically dot, dot close function will be called and we need not to worry about that part of it. So this will be the format we will be using, and this is the better format. Do apply. 42. Write and Append: Hi there. In this session we will explore a few other modes in which we can open a file. So we will start with the right mode for to open a file in write mode, we have to add w here, which will indicate that now we are opening this file in write mode. The point here is that when we open a file in write mode, it deletes all the content, so it will remove everything that is in our file. So it will give us a new clean file. So now this file.js read function will no more be available because we are opening it in write mode. So I will remove this part here. And we will open it in write mode and we'll write something in our file. So we have to call a function right here that will write some text in our file. Let's say it's my name Hamza, I will run it. And as you can see in our file, Hamza is written and everything that was previously there is gone. I will run it again and add something else like John. And now we will see that it has removed everything that was previously there. So now this is a right function. What if we do not want data of that file to be removed? Then we open that file in append mode for that we use a. So now we have this here, John, I want to append data to this file rather than removing the complete file and then adding data to it. So I will say at some value here, like you can say, Good work. Okay, now it will append this value to whatever we have in this file that is John. So I will run. And as you can see, John, good war. So it has appended data value, that string in our file. Now I will again add right mode here and we will see it will remove everything and it will keep the good work. They are only. So woodworkers, Dear John is removed. Now there is an another function in write mode that is right lines that I can choose to write multiple lines. This function takes a list, so I will give it a list and there will be a few values. Like let's say first of all, you is Hamza. And then I have to specify slash n for new line. And then the second value I will give John. And third value I will give up the right amount. And in every line I have to specify backslash n to move into the next line. Now I will run this. And as you can see, all the values have been added by using destroyed lines function Eigen give a list where I have multiple lines in there. So these are the two modes, right? And append that we can use to write in any file. So that's all from this session. 43. Count words: Hi there. In this session we will do it quick fun example in which we will read a file and count number of words in that file. So this is our file. It has 123456 words in it. Now, we will write a program that will count all these words. So we open a file, and now in this file, I will get all the data from this file by the read function. So I will say data is equals to file dot read. So what it will do is it will give me all content of this file in this data variable. And now I will split that data using whitespaces. So as we know that every word it's spread separated by other using a whitespace. Here, there is a whitespace, so let's do it. So data dot split. On the basis of what? If we leave these parenthesis empty? It will automatically split that data on whitespaces. So I will get the result of this data in a list. So I will say words list. Okay, now we have this words list in which I am splitting that data using whitespace. So this word list will have, will have all the words. And now finally, I will print word list dot length. So what it does here is it splits the data and we get a list, and then we print the length of that list. Let's see. Okay, It says six and our count is correct. Now I will add another, like another string here. Now it should be equal to seven. So as you can see in the output, it says seven. So our code is working. Now, what we can do here is we can learn this split function by now currently it is splitting it on the basis of whitespace. What if I wanted to split on some other special character? Suppose I wanted to lay down colon. So now if I add a colon here, what it will do is it will split the file on the basis of this special character which I have here. So as you can see now when we split this file, this is the first part, and this is the second part of files, or the count should be two because it is splitting it on the basis of colon. And as you can see, the output, it's two. So now let's add in another column here. So now it should be three because the spreader that we are, the tin we are choosing to split it is colon so it's three. So we can use this function. Now we have successfully counted all the words in our files and that's all from this session. 44. Task 1: Welcome. Your task is to make a program that will count number of characters in a file. So what it will do is it will open a file and process it. And finally tell us that how many characters are in that file. And it has to Dell for both, like including whitespaces and excluding whitespaces. 45. Solution Task 1: Hi there. In this session we will count number of characters in a file with and without spaces. So I have a file here and it has some texts. So what I will do here is I'm opening that file and I'm reading that file in this data variable. So I will print length of this data. So what it will give me is the length of this data and as you can see, it's 34. So there are a few points to note here. The actual length of this data is 33 with spaces. But why is 34 here? Because here we have a slash n, that is for new line, and that is also included in the corrector. So we will learn this. I will just reduce this debt so a little bit so that we can count it easily. Now, I will run this program again. And as you can see, it says 16. So let's count it. First for four legs and then a whitespace five, and then this L is six, and then a white, and that is a new line will be seven. So we have seven characters on first-line. And then in the second line, we have eight, 9, 10, 11, 12, 13, 14, 15, and 16. As you can see, my output is 16, so I will just move to a next line here. Now we have three lines because I have moved to next line and here is slash n is added in the second line as well. So I will run it again and we will see, and as you can see, it is changed to 17. Now that slash and has been added in this file. So now we will modify our program to counter the doubt spaces. So I will just remove this brand here. And to count without spaces, first of all, we will have to get all these words in a list. And we will see, I will split that data into list. Data dot split. So I'm splitting this data on whitespaces. Now I can make a variable count of words, and then I can initially put it equal to 0. And then I will have a for loop to iterate over my list for word in my list. So I'm getting every word in my list. And then what I will do is I will add this variable and plus equals length of every word. So I will explain it now. So what I'm doing here is I'm getting the length of every word and then I'm adding it into count of words, which is initially equal to 0. So what this will do is it will always add these two sides on left and right and store them in discount or words variable. So it will always count its left and right and keep on updating value of this count or words variable. So dass plus equals two means here. Now finally, when I get out of this loop, my count of words will be updated and I will print that count of words. So I will just run this program. And as you can see, it says 30. And now let's count it. First for four days and then five for this one. 6, 7, 8, 9, 10, 11, 12, and 30. So it gave me an accurate count and slash and is not included in this case because we are splitting all words, getting all words in my list, and then I am adding them in this variable and then printing by this loop, we can further simplify these two lines which I have here by some function I will show you. So let's simplify this. I will say some and then I will put this length and then w, vD, that is our word. And then I will copy this for loop here, put it in a single line. So this one line solution will do the job for us. And instead of this, I will just simply print whatever I get from this. So I will run this and then I will explain this. As you can see when I run this, the output is same 13, but it's, it seems to be more precise. So what it does here is this sum function will add, it will, first of all, our for loop will iterate over every word in our list. And this length world will keep on adding those characters in that world. So because we are getting the length of that word, it will count characters off that word and we will iterate over every word in this list as well. So this sum function will add every word characters, like if they'll keep on adding those. So this is, this seems to be a more better solution when we are working with this. And this work fine. We can add another value here and we can see the output now there are four or more characters at it. And I will run this again. And as you can see from 39 and goes to 17. So that's all from this session. 46. Task 2: Welcome Joe. Task is to make a program def loop count the number of occurrences of each word in a file. So what your program does do is it will open a file, process it, and tell us that how many dimes each would exist and that particular file. 47. Solution Task 2: Hi there. In this session we will write a program that will count number of occurrences of each word in a given file. So we have a file here, it has some words. So now we will count each word in this file. So first of all, what we are doing here is we are opening this file in read mode, and then we are getting all the data in this data variable by reading the file. And then in this words list, which we have here, this is a list of each word which we have in this data. So all the words are in this word list. Now, I will loop through each word in this and we will print the count off there. Let's see how four Word invert list. So now I'm iterating over every word in this word list. And I will print var1. Then I will add concat, this string count word, or I can say equals 2, then I can concatenate with, now I have to count these words. There is a function that we have in list. So what I will do here is I will write the name of my list and then I will call a count function on this list. So it will count that word, which I will give here. So it will be the word which I have here. So what I'm doing here is I'm getting each word in this for loop one by one, and then I am printing dad. So this is just to decorate things like I am writing their vote and then equals two. The main thing is done here in wordlist dot count, and then I'm getting that word, put in debt word here one by one. So first of all, it will be high, like this. Hi there. So first of all, the word will be high and then they are and it will keep on going and then it will print for every. But there is a drawback of this approach. I will run this and you can see, so we have a little error here. It says Can not concat, string to an integer. So this returns an integer that is count of words, so it cannot concatenate with all the strings. So what I will do is I will put it, I will convert it into a string by using this function. So SDR, this will convert that integer into strain. Now I will run this again. And as you can see, it printed every single word that how many times it is high as one theory is one. Lets us do time, learn, and every cool is three times. But there is a drawback that it printed for every word. Now we have two. Go to our second approach that will be more better and it will also involve less, less code. So what does this approach gives us the correct result, but there is repetition here that if let says two times, it is again telling me that lets us do time because it iterated over every word here in this list by our loop and it counted the words in there. Now, I want that every word should be single time and it's count should be there. So we will be, I will commend this part here. We will not be using this for loop approach anymore. I will have a input from collections library which we have here ival import Counter plus. So this counterclockwise counts all the verbs and they're like, how many times they are repeated in any list. So what I will do here is I will print, I will call this class counter, and then I will pass in the list which we have here, verbs list. So what it will do is it will count and it will do all the work for us. So now I will run this again. And as you can see, it says Google is three times and it is not repeated anywhere as every single word handling two dimes, Let's 2 times file too. Learn to an, all, all words are there and no one is repeated. I will add another thing here like handling. So now handling is three dimes and high is two times. Now let's run this again. And as you can see, HI is two times and handling is three times. So it changed the valued, updated that value there. So this is a better way of doing it. We can use our existing classes, which we have there in the libraries to do different stuff there. So that's all from this session. 48. Make Connection and Create Table: Hi there. In this session we will make database and add table in our database. So to be working with SQLite, first of all, we need to import a module named SQL lite three. So this module will provide us with all the necessary components that we required to work with SQLite 3. After that, I have to make a connection with my DB. So to make a connection, I will make a variable connection. We can name it anything, and then we can make SQLite 3 dot connect. So this function Connect will connect to our DB. In these parentheses, we have to provide the name of our database. Let's say our database name is database dot db. As you can see here, I have a file Python dot py and which I'm working right now, but there is no DV. After I run this command, SQLite dot connect, it will make a DB for me in the current directory. So I will run it. And as you can see here, we have this database dot db there. So now we have successfully made our database and that appeared in our current directory as well. So now our database is ready. Now it's time to add table into our database. And we can do that by making your cursor. So I will make it cursor by using our connection which we have. This cursor will be responsible for giving us all the functions that are that we can use to run SQL commands. So this is an important step here. After making this cursor I will, I can execute different queries in my DB. So by using this execute function, I can give any query here which I want to run. So I will add three goes here. This will allow me to add multiline string. So simply what I will do here is I will create table. After writing this create table, I have to provide the name of the table, for example, if it is employed. So now it will create a table named imply. And then I have to provide the column names that I can go in next line and add those. For example, first of all, we will have the ID which will be primary key that will uniquely identify each row in our table. So as Reagan have different employers with same name, for example, there are two to three employees with named John. So how we can differentiate between them? They can have same name. So to differentiate, we have a primary key that is unique to every record in our db. So first of all, I will make ID. And to make it after Dad, we have to provide the datatype of this. For example, we have like text, integer, real, realists, four decimal points. So I will say it's an integer. And then I have to add a primary key. Primary key texts, this will indicate that this ID is a primary key. So I only have to add this primary key where we have to add, where we have to tell that this particular column, it will be primary key and it will be integer value. It will automatically increment this value. After that, I will provide the name. Employee will have a name and we can say it's a text, this is the datatype. After that, this is the column name and then this is the datatype. And then we can have email. It can also be of type text and then we can have salary. It will be real. So we have a few columns in our table. Now, when I will run this, it will create this table in my database dot db. So I will run this. And as you can see, it, it made that table. So how we can know that whether it worked or not, I will run it again. So by running it again, as you can see, it tells me that they will employ already exists. So by this, we know that our table is already dear by the first drawn which we did. So that's all from this session. And next session we will add some values in a table which we have just made. 49. Insert: Hi there. Now it's time to insert some values in our table which we have just made. So to insert values, I will again write it Curie and I will say cursor dot execute. So in this function I will write my Curie in this three codes. And now it will be insert into and the name of the table we have employ. Then I can specify the values which I want to add there. So I can simply write values. And it will be in the two in parenthesis. I can provide, for example, ID first one is ID, I can say one, and then the name. So I can say John. And then the email. So email will be anything XYZ at the rate a, b, c.com. So after that we have salary. Lets it be 1, 0, 0, 0, 0, 0. So all the text which we have needs to be in quotes and all integers and real are the doubt codes. So what this query will do it, it will insert into our employee table these values and they need to be in the sequence in which we have these four resemble ID name, email, and salary. But if you want this ID to be auto-generated because it's a primary key and there are no duplicates in there. We can have different format here. What we can do here is after employ, we can specify column names in which we want to add values. So I will specify name, email, and salary. So now what I am saying here at these three values, I will specify them in these values and I will remove this one from here. So these name, email and salary will be added and this ID will be auto-generated. So in most cases we want that because we do not want to remember that where is the count of ID? So what we will do here is we will provide the name of columns, which we want to add value four, and then we can add values for those columns. We're going to also just simply add for some specific columns as well. For example, if I only want to add for name, I can simply leave it there and then remove the other values. So it will add the column name. For the, for the column name name, it will add this value John, and for the other values, it will keep the null. So in the next session we will select these values and we will print them. 50. Select: Hi there. So we have this insert query here. Now it's time to select some values from our DB and print them so that we can know that if the data is going in our DB or not. So we have this employee, John with id1. If I run this program, it will add this employ in our DB. And the other way we have here is like we can have names here of variables and then we can add, we will look into both of these. Now, I will just make an another Curie cursor dot execute. And now this time this will be select curie. So you're selecting from a DB slept star from the table name that is implied. So what this means is select star means that select everything that we have in there. So it will select everything like all the rows in this employee table. So what I can do here is I can print this and we can run this here. And as you can see, it shows up some like object value here, so the references to it. So we can just call in another function on it that is fetched one which will fetch one row from there. And as you can see, it printed the row which we added where ID is one name is John, and it isn't a specific format. We can also remove these, you, this character. We will learn that in future. So for now we have our row here with all the values. Now if I will add an another, imply that C, I can say Hmm, so I'm changing its name. So now it will give me error because I have this one here and that is repeated. So as this is an ID, so this cannot be repeated. I will run this. And as you can see here, it says unique constraint failed. Why? Because this one was repeated for both employees and it's a primary key, ID is a primary key. We cannot repeat this, so I will change it to do, and I will run this again. So as you can see, it shows me the first row because what we are doing here is we're calling fetch one function. We can also call fetch all are fetch many. I will call fetch all, which will allow me to show all the rows. So now you can see I have all these rows here, so we have two employees, John and hump Zaire. Now, what I can do here is I will just command these two lines here and we will see the output. There will be nothing in output. As you can see, we have empty list here. So why this happened, we have to employ is inserted. So if I commend this, there should be no change. I should get these two implies, but why I'm not getting these two employees. So there is a reason I will uncomment this part here, and I will add connection.com here. So what this Commit function will do is it will apply all the changes that we have made. So if this phone, we do not call this function commit, it will not apply the changes which we have made. And after this commit function, we will also close our connection. So whenever we are done with applying changes, we will add this Commit function and then we will close our connection. So this is not necessary part of commit, but we can do it for like it's a good practice to close our connection. But discriminate function will work without disclose as well. This is just two, shows you that we need to close the function as well when we are done with it. So this has nothing to do with above part. So I will just run it again. And as you can see in the first time it showed me the values. Now if I will try to run this, again, it will show me an error because it says the unique constraint field, because these values are now already there. I will commend this. So now previously it was showing me null, but now when I will run it, as you can see, these values are there. So these values are persisted in our db when we call this function commit, commit should be always there. Now what we can do here is we can just simply change some format here which we have. I will just remove this second part here because we have that employed there. Now I will change this to up the lemon. And now instead of given this value here like ID primary key, we want it to be auto, increment it. So what I can do here is I can simply add these column names, name, email, and salary. What it will do here is it will auto increment the id column here. Now I can run it. And as you can see, it added up the lemon there and it added the value ID3, widget auto incremented. I will run it again. And it has added the ID for with the same name up dollar amount. Now these two employees with the name of Dr. Amman are two separate employers which have different IDs. So we can have multiple employees with same name. So now this format allow us to add this, but in the previous format, if I reverse this and add an ID here, so I will have to manually add that ID here. And if I do not give this ID, it will give me error. So as you can see, table employee has four columns, but three values were supplied. So we will restrict with our previous format that is providing the name of columns. And we will remove this from here. Now instead of fetching this all here, which gives us these in a form of a list and it has some characters there as well like this you. So what we can do here is we can iterate over our list one by one and print the values as we want. So what I will do here is I will remove this fetch all here, and I will get this cursor dot execute select star from employee in a variable I can say rows. So these are my rows here and I will iterate over these rows one by one. So for row in rows, what I will do now, I get all these rows in one by one in this row variable and I can just bring that. So I will say print. So I will have to add, for example, I will say ID is, ID is equals to, and then I can concat it with row. And then the index. So on 0 index I will be having ID and on one name and they are in the sequence like name on second index and then email on turd and salary on 4. So what I will do, I will copy this here and I will add it for other values as well. So I will say name and it will be one, and email, it will be on two. And then we have salary, it will be on three. So I will run this and we will see output. So, so it says string and integer objects, as we know, ID is an integer and we cannot concat integer with a string. So name is fine and e-mail is fine. But we have salary that is also real and that is decimal point value. So what I will do, I will convert this into string. So by adding this now it will convert this value into string and printing the output for salary. I will also do that again. And I will now run this again. And as you can see, all the record is printed in my output ID one John and its email salary than id2. Similarly, for every imply, it's printed in the output without any special characters in there. So that is how we can get all individual values from there. And that's all from this session. 51. Where Clause: Hi there. So we have some data inserted into our table. As you can see, we have six entries here, ID six is the last one. So now, as you can see, we are selecting everything from our employee table. This asterisk sign means that we are getting all the columns. So as you can see, id, name, email, and salary. So these are all the columns in our table. So I can also restrict these two few columns rather than bringing them all. For example, I can say bring only ID and name. So what it will do is it will select id and name from our employee table instead of bringing everything. So I will commend this part, and I will also commend this. Insert Q30 so that we do not enter anymore records in our employee table, we will respect it with six. So now let's run this. And as you can see now, all values with their ID and name are printed and rest of the table is not there. And if I will try to uncomment this, do get the email and salary as well as you can see, it gives me an error here, that double index out of range. So it only we have 01 here, but 23 is out of range. So I will commend this again. And when I run this, it works fine and give me ID and name so I can define number of columns here instead of asterix sign as well. So again, I will change is the asterisk sign to bring all that record. And now we will learn about where clause. So okay, We are getting all the data. No, it's not the case that every time we want all the data of our table to come, there are times that we want selected rows to be there. So how can we bring selected rows from our table instead of bringing all that data from our table. So we can do it by using a where clause. So we're clause after this where clause, we can define the condition on the basis of which are record will become in for example, I can say we're ID is equals to one. So now I'm specifying that bring the record whose ID is equals to one. So I will run it. And as you can see, only row with ID 1 is here and rest of the rows are not there. So I can also add a range like this. If id is greater than one and I can add it and here, and ID is less than, let's say four. So what it will do is it will bring all the IDs in between 14, so it will be only 23, so two records will be there. Now, I will run this. And as you can see, id2 and ID3 is there and rest of the data is not there. So these are the conditions if I want to include one as well, and I want to include four as well, then I will say ID is greater than or equal to one and it is less than or equal to four. Now four records will be there. As you can see, ID 1, 2, 3, and 4 are there. We can give these type of conditions here. And for example, if I do not want it to be on ID, I can also put it on name, like names equals to, let's say I only want to bring this one. So I will say abdel Rahman. And as you can see, we have four records there, where name is Abdul Rahman. So if I will change it to John, I will get only one that is on index one, ID 1. So we can have different conditions here depends on how we want to bring data. So here, if our curious on single line, there is no need for these triple quotes here because they are for multiline. I can only distinct it to single quote as well and it'll work fine. So when I run this, it will work fine. As you can see, it brought us that data from our table. So this is how we can work with our curie and we have learned about AND operator. We can also have an OR operator. So if we want to bring record with the name John and Hamza, we can add our operator here as well. And they can then add name is equals two. It will be a Hamza. So now what it will do is it will bring two records where name is equals to John and Hamza. So that's how we can add different conditions here. And, and, OR operators can be used. For example, if you want to add on the salary as well. Currently we have all salaries equal to 100. We will update these salaries in our upcoming session by using our update curie. So for now, we have learned about this Curie and how we can use a where clause in our query. So that's all from this session. 52. Delete: Welcome to this session. In this session I will guide you how to delete records from table. So currently I'm running this select jury that is getting all record from my table and that is six records. The first one is John than Hamza, and then we have four records with siem name, that is Abdul Rahman. What I will do here is I will delete these three records here that are on 456 and we will keep the record on ID3. So how I can delete these three duplicate records here, what I will do is I will write a curie cursor dot execute. So now I have to define my Curie delete from table name. So by saying this delete from imply what it will do is it will delete all the records in my table. So I don't want to do that. What I will do is I will add a where clause here, which will, where I can define condition on the basis of widget will delete rows. I will say ID is greater than three. So what it will do is it will look for the IDs that are greater than three and we'll delete, all 456 will be gone. So I will run this and we will see the output. As you can see in the output. Now we have only three records. Record number one, Record Number 2, and record number three. So all of the records or deleted by this Curie that we have here, Delete from employee where ID is greater than three. So we can have different conditions here depending upon what we want to delete and how much record we want to delete. So this URI can be used if I remove this where clause from here and run this query delete from imply it will remove everything from our table. As you can see in the output, there is nothing. So everything that was in our table is deleted now by this command Delete from employee. So that's all from this session. 53. Update: Hi there. In this session, I will guide you how to update records in table. So to update and your core, we have to write a update Curie, currently we have three entries in our table. That is Jon Hamm signed up to remand. Now, I will try to change the second entry name from Hamza to Muhammad hams up the RAM. And so it will be my complete name here. So I will write a curie here. I will say cursor dot execute. I want to add it on multiple lines. So I will add these three coats and then update. I want to update employee. So update keyword is used and after that, I will write set SAT, SAT where I can provide the name of columns and the new values which I want to enter the ER. So I will say name equals two. So I will write moment comes out or demands, so it will update this value. And so it does not know that where it has to apply this change. So I have to tell the verb bought here as well. We're, will take the condition on which this change will be applied. So I will save your ID is equals to 2 because we know Id of our Hamza entry is 2. So in this verb clause, as we have previously also learned about this, we can add multiple conditions as well depending upon what we want to do here. So I will run this and we will see the output. As you can see in the output, the name has been changed to Muhammad comes up that Oman where ID equals to 2. So the change has been applied. Now here in this part offset, I can also provide multiple column names and values. For example, I also want to update the salary. So I will say salary is equals to 2 thousand. And now I will change the name of first entry, that is John to Peter. So name to Peter and id1. Now what I'm saying here is setName to Peter and salary 2000 we're ID is 1. So currently the John and salary is 100. So I will run it. And as you can see, the name has been changed to Peter and salary has been changed to 2000. So we can give multiple column names here and the UN also be of different conditions here. 54. Safety points try catch and ?: Hi there. In this session I will guide you about to safety points that we need to keep in mind and implement in our code while we are working with such code where we are connecting with DB and writing theories. So these two points are very important and we need to implement them to write a very skewer code. So the first one is, for example, if you mess up with our DB name or something like, I will write something here like this. Okay, So when I will run it, as you can see, our code crashes and it says operational error, unable to open database files. So how to avoid this? So if we feed, DO NOT must fit our DB name and something. We, okay, we have this employee table and rewrite two E's instead of one. So it will again crash. And Azure 20, it says no such table employee. So what I have to do here is to avoid this, I have to put all of this and try except block. So I will write dry here. And to fix the indentation, I will select all of this and press Tab button on my Mac so it will fix indentation and then I will add the except block here. And I will catch exception in a variable. And I will print that exception. So, okay, I will move it to next line. Now I will run this again. And as you can see, it says no such table employ. But it ended up in a very sophisticated way. And it does not show us that big crash message that we always don't want to see. So it's now if you mess with anything inside our code, it will get it done and if we write it, okay, it as you can see, it worked fine. I will change. I will again master database name and we can see if it worked for data as well. So as you can see, it says unable to open database file. So it's good to write it in, try except block. And the second is, there are a lot of time we are getting values from variables, python variables. So it's not always the case that in our curious like this, we will want to hard-code these values like name and salary. We will be getting it from user. If we have, if we have a GUI where user is inputting values, so if he and puts the value, we get it in a variable and then put it here. So what is the conventional way of doing it? First of all, we will do it with conventional way. And then I will tell you about the drawback of data and then we will fix that. So we will make a variable name and we will add there, for example, John and salary. That is, let's say 1500. So we can assume that these name and salary will be connected to our user interface and user will be entering these values. So what was the conventional way of doing it? We will remove these direct values here by the conventional way of doing it as like percentage as for string. And then for salary we will add percentage d. And then here we will add percentage sign and then the values name and salary. So this will work fine here when I will run this, as you can see, the value at ID1 is again change to John and the salary to 1500. So this, this way is vary in scale. When we are working with curious, this will become very insecure and it's to one ruble to SQL injection, that is attack and this kind of curious. So to avoid that and to make our code more safer, we use a question mark sign in SQL queries. That is, I will remove this part here and add a question mark sign wherever I want a variable to be used. So in name and salary, I was use a variable here in this example. And then what we have to do is we have to provide a tuple instead of just adding it as like a conventional way. So I will remove this sign here and we have to pass it to the second argument is always execute curie, this execute function. So in this execute function, the first parameter is the string, and then the second parameter is the tuple, which we want to give. So this is a tuple with name and salary, and these two customers now will be replaced by these, will be using these values now. So I will change it to John S and salary to, let's say 3500. And I will run this. And as you can see, the changes have been applied to our employee with named John and Jane to John S and salary has also been updated by using this question mark sign. So this is very secure way of doing it. These small minor things make our program more usable and user-friendly and very skewed too different. And so we have to take care of these things while writing a good program. And if we ignore these things, our program becomes less reliable and more vulnerable to attacks. So that's all from this session. 55. Regex Introduction: Hi there. In this session we will learn about regular expression. It's also known as graduates. So this graduates is mostly used for searching and matching. If we have an e-mail address that we want to validate or if we have any did that we want it to be in a specific format or any other specific format. Or if you want to search in file or in string, we can use regular expression. So VDD, we don't want multiple, add the red signs in an e-mail address that will be invalid. And if we want our data to be in a specific format and not in any other format. We can use regular expression. So the regular expression for email address that can validate this email is this. It seems a bit complicated at first sight, but if we know what these special character means in this rejects, it becomes very easy. So let's have a look at some of them. So backslash d means that it can be any digit from 0 to nine. Backslash w means any alphabet from a to z, 0 to nine, or underscore. And backslash S means whitespaces and other characters like newline, etc. And dot operator means anything except newline character, that is backslash n. And then we capitalize these words like capital D, capital W, and capital S. It is used for opposite of what we have in its original meaning. So everything will be opposite when we use capital. So backslash d when capitalised is anything except digits from 0 to nine. So we have some repetition symbols as well. For example, asterisk, which means 0 or more repetitions, then plus sign, which means one or more repetitions. Then question mark sign, which means 0 or one repetitions. And then if we put braces, then we can define any number of repetitions that can be there. For example, M repetitions here. And if it is M and N, Then it means m is lower limit and n is upper limit. Similarly, as we have in range function, the two here will be lower limit and it will be upper limit, but it will not be included. So it will be from two to seven. 56. Raw String: Reuse a raw string for writing regular expression. So a normal string and biotin is written inside codes. And to write a raw string, we add our before we add goats. So what is the difference between normal string and raw string? If we bring the normal string and it has a new line character inside, what it will do is it will split a string into lines that is normally will be on first-line and string will be on second. But if we have a raw string, so what it will do is it will ignore our new line character there and print the string as a raw string and the output that is in its original form without applying any special character there. So why we do it? Because in regular expression we have backslash used for some special meaning as well, when combined with different characters. So we want to ignore that what it's meaning is in normal string and we want to use that in a regular expression for the meaning that we have specific to regular expression. So that's why we use a raw string and regular expression. So now let's jump into the code editor and write some code. 57. Regex Code: Hi there. In this session we will work on this e-mail string that I have here and we will try to validate this. So I have this e-mail string as a second argument in my search function, and now I will write a regex. So to validate this, we analyze the string and we see that we have alphabets and integers that are before this add direct sign, which I have here. So how I can, for this part, I can add here either a set where I can have Eigen, say like a to Z or a to Z. And for NTU or 0 to nine, either I can do this or I can simply replace it with a backslash w. That will work good because backslash w has that all including underscore. So after Black such W, I need to add a plus sign, which means that one or more. So I will not put asterisk sign here because that will mean that I can have 0 or more. So I don't want to be this part of string to be empty. That is before this anterior sign. There should be something before this add direct signs are that it's a valid email. So after this, I will add, add direct sign here. So what it will do is it will force it to be having this add direct sign here. So any other special character will fail. So it will not allow any other special character. So I cannot add a dot here which has everything especial character and vote. Because in an e-mail address we want it to be at direct sign. So I will add, add direct sign here. After that, we see this alphabets there, that is email, so that I can Have by backslash w plus again, which will allow me to have one or more alphabets there. And after that I have this dot. So we know that DOT has a special meaning and rejects as well. So how we can just wanted to be exactly dot there for dad, we can add a backslash and then dot. So what it will do is it will not invoke the special meaning of dot. Instead it will use it as it is. So we will, we will match this dot and after that we have this gone there. So here we want it to be exactly gone. We cannot write backslash w plus here, because what it will do is it will allow everything. So we will wanted to become, so I can simply write column here which will validate and walk. And here it will find calm. And if there is anything else, it will fail there. So I will run this and we will see the output. As you can see, it really dated my e-mail address. So if I change this to anything else, for example, net, it will not work. So as you can see, it gave me an error here because it was expecting it to be calm specifically. So we found net there and it didn't work. So I will change it back to calm and it will work again. And now what we are doing is we are searching for this rejects in this email address. So what if I put a dollar sign in the beginning of this email address? It will still work fine because it it found that combination after this dollar sign or if I put this e-mail address in my this long string, somewhere like this, and I change the second parameter too long string and I run this, it will work fine. So why? Because what search function does is it parses the complete, it starts from the very beginning of your string, and wherever it finds the magic gives an output. So while it was searching for this rejects in my long strand yet founded there in the end and it gave me the results. But in case of email address, I don't want that, I want that complete string to be just email. So it should not ignore this part of the email and it should exactly match that. So what I can do here in search function is I can use caret sign and dollar sign for the start and end. As we have learned before, dad will fix the problem. But instead of the search function, what I can do is I can have a match function here. In this match function, there is no need for that carrot and dollar sign what it does it, it finds for an exact match from the very start of string. So what it will do is it will start from the very beginning of the string and it will try to match. And if it doesn't find that magic will fail. So it will give us the exact thing which we want here. So I will again remove this part here and change this long strand to email so that we can validate this. And now there is a dollar sign at the beginning of this, which search function a validated. Now let's run it the match function. And as you can see, it gave us an error here because from the very starting, it found a dollar sign which was not part of this backslash w plus. So I will remove this dollar sign and we will run it. And as you can see, it validated our email. So now it expects it to be exactly what we have given in this rejects. And if anything else is there, it will fail. So what if I put the dollar sign in between here? I will change the sign. Let, let it be percentage sign. So I will run it again. And as you can see, it again gave us an error because this rejects didn't exactly match with the string which we have. Why? Because before this add the red sign, what it expects is backslash w plus. So any character that is now under this backslash w can be there, but we know that percentage is not part of backslash w. So what it does, it, it started from the very beginning, x was the part of backslash w, So find them via wass part. That was also fine. And then z was also part of that. It validated it. But when this percentage sign cane, it was not part of this backslash w. So anything other than this backslash w plus was to be this at the rate sign. Because we said all the characters will be followed by this sign. So we are expecting it to be at the rate sign. And before that we are expecting backslash w plus this failed because of this percentage sign. And I will remove this again and we will run. And as you can see, it works fine here. And if I change this part again to net, it will also fail. So in the next session, I'm going to give you a task after data, I will give you a solution for that. So I will give you a hint that we put in this column inside of a group. So this will help you in doing your task that I give you in next session. And then we will work on this net bot as well. So that's all from this session. 58. SET and long string: Welcome to another session of regular expression. So in this session we will try to work on this long screen. So previously we were working on this name. So now I will try to change the second argument too long, strained instead of names and now we are given this rejects, do this long string. So I will run this. And as you can see, I'm getting m and y from this long string. So why is that? We are seeing this word should be 0 to 1 times by adding this asteroid. But what it does is it start comparing it from the start of any string. For example, it will start with em. It comes under slash w, so it will validate that and then it will go to y. So it also comes under dad, and after that, it has encountered a white space. So there is a whitespace now and we have not specified dad in our register anywhere. So it ignores that and stops right there and gives us the output that it has found there. So I will add slash S for space. Now what it will do is it will find for the birds that are due like 0 to one, and then it will look for a whitespace as well. Now, it will get into this whitespace. Then after that, I have not specified anything yet. So it will stop right there and it will give me my and this part of the string. So I will run it. And as you can see, it gives me my and a white space there. So it gave me a whitespace. And now if I add asterisk sign here, it will give me 0 to any number of whitespaces there, but we have a single whitespace here. So it will give me the same output, but if I increase the whitespace here, it will give me two whitespaces as you can see, my and then to whitespaces. So it gives me two whitespace. And now how I can tackle this, so that I get this all string here which I have. So for that, I will put it inside of a set. So I will remove these asterix signs and I will put it in a set that is by these two square brackets. Now, I will add this asterisk sign outside of this set. So now what it will do is in complete string, it will find these two things. If they are there and they are repeated from 0 to 1 times, it will give me those. And as soon as I will get a, anything that is not specified in the set, it will stop. So you will see this, I will run this. And as you can see, it gave me complete string data as My name is Hamza, we are learning Python to grab. So what it does, it, it iterated over that string and it matched everything there. So now if I insert a special character here, like percentage sign, now it's not part of this set. So what it will do is it will stop right here after this whitespace, after Hamza. So I will run this. And as you can see, it stopped after that whitespace off grounds that because it encountered especial character that was not specified in this set. So now I will try to add that. So I can add, simply add this special character here. Now it will also match this. So as you can see, the percentage sign is there as well. But as you can see here, together is not complete here. Why? Because this object is showing us only limited correctors, but we are mentioned that as well. So I will just modify this and print it so that we can see the complete string and that is not like trimmed here. So what I can do here is I can get this thing out. So I can simply do it by adding group as well, but I will make it simplifies. So I will show you first. So if I write this group here, it will, what it will do, it will give me the complete string, as we can see together is complete now. So I will try to simplify it by not putting all that in a print statement, but getting it in a variable. So I will say search result and get that in here. So what I'm doing here is I'm getting the output of this in my variable search reserves and item remove this group here. Now. And what I can do, I can bring this search result and then grew. So, okay, so this group will give me the same thing which I have here now it looks much better here. So now let's learn a little bit more here. So what if I put any integers here, let's say 90 and 80? So these integers are covered by this slash w because we know the slash w literally means that set from a to Z, capital a to Z and integers and underscore. So I will run this. And as you can see, I'm getting 90 and 80 as well. So I will replace this slash w with what it literally means is a two. So I will write it here. A to Z and then a capital a to capital Z, and then 0 to nine, and then underscore. So what slash w means is this. I will run it again. And as you can see, same output. So I can just, if I'm defining these for this, Italy, Ireland remove this underscore as well, or I can just simply give a to Z and capital a to Z. So now I'm not defining integers here, so I will run it and it will not show me integers. As you can see, integers are gone. So if I define them here, they will again appear in my red rejects output. So, okay, now we will, in the next session we will learn about starting and ending of a string, how we can specify and restricted to some specific starting and ending that. That's all from this session. 59. Start and End: Hi there. In this session you will learn how to match starting and ending of anything that we are searching through rejects. So in this string, long string that is starting from my ending on a t. So I can define, I can restrict this rejects to say that it should follow this. Like I can restrict it to my start and 80 at the end and different other as well. So how I can define this, that it should start with my online. So for dad, I will add this caret sign and then I can define anything from which district should stop. So I can write M here. First of all. So what it will do is it will search for this M on the starting. So I will run this. And as you can see, it gave me the output. My name is Holmes up, but if I change it from M to Z, what it will do is, as you can see, it shows me an error because it says NoneType object has no attribute group. So non diabetes giving me that, none widget returns in case it does not find a match. So I will write my hair and I will change it to m. Now I'm saying it should start with my so I will run this. And as you can see, it worked fine. And if I change it from My to something else me, it will not work there. Again, it shows me an error. So this is how I can match starts or I can also give multiple patrons there. For example, if I wanted to start with M and then two 0s. So what I can do here, I can either write explicitly me m, e, it will work fine. But if I want to specify different 1000 like I wanted to be starting from my as well and Mr. as well. So these are two different strings. Now, how we can define them? I have to define them inside of a group. So I can add a group BY these two round parenthesis. And then inside these I can define like my and then this OR operator. And then our for Mr. now it will any of these starting with a match here. So I can run it with Mr. And it will work and I can run it with my son and I can see as you can see, it works. But if I change it to anything else, I have, right? I've changed it. Now as you can see, it gave me an error here. So it looks for these two starting points. So if it is there, if strings start with these two strings that I have here, it will work fine. So I will quickly change it back to my and I will run it again at revoked. Fine. So now what if I want my screen to be only starting with alphabets, not integers or any special characters. So how I can define that? I can do it by specifying a set here that will say a to Z and capital a to Z. So now it will restrict it to any alphabet that we can have in the start, not integers I will run, it will work fine. But if I put an integer here, let's see nine. So it will fail, as you can see, it failed there. So I will just allow it to be an integer as well by adding the 0 to nine here. So it works fine. Now I can add a special character here at direct sign. Now that add direct sign is not defined in this set, so it will fail again. So as you can see, it's says that object has no attribute group. So this is working fine. Now we can move to the end of the string, so it's working fine with the starting. Now I will remove these two and I will just shift it to alphabet. So it should start with an alphabet only. So now in the end of the string, I can define that by using a dollar sign. So this dollar sign, anything that will precede this dollar sign will be required at the end of the string. So currently we have this 0 that is an integer at the end of string. So what I can do here is I can say slash d, that is used for integers. So it is largely is this 0 to nine. So I will run this again. And as you can see, it worked fine. But if I put any alphabet there, let's say a, it will fail because it was expecting it to be slash d at the end. That is any integer. So I can simply remove this and run it again, it will for fine. Or I can also provide a string. For example, if I wanted to be ending with a 0, so I will run it. And as you can see, it worked fine now I will change it to 70. So as you can see, it gave me an error there. So I can define these things as I can define it in the starting Eigen also defined groups at the end as well. So I can say it should, it can be AD, or it can be 70. So what I can do, I can add this. So I will run this again. And as you can see, it worked fine for 70 and 80 as well. And when I will change it to 60, it will not work for dad. So we have defined a group that it search for and starting and ending has been defined in here. So that's all from this session. 60. Match function and email validation: Hi there. In this session we will learn about regular expression. So I will go ahead and import a module here named RE. So this module will provide us with a few functions that we can use to apply radio waves on strings. So now I will go ahead and add a few strings here. I have these strings, like the first one is my name, and the second one is a long string. And the third one is e-mail. We will work on these one by one. So to apply rejects on any of the strings, I have to write R, E and then dot. So it is showing me a few functions like search, find all split, match, and it a few more so I can use them. First of all, I will use this search function here. So the first argument to this function would be the patron that, so that regular expression data I want to apply. And the second argument will be the string on which I want to apply it. So if it has a name, then I will have to provide name and then long string and email anything. So the first argument is a regular expression. I will use a raw strain. So using the raw string two, ignore any special character that we have in normal string in Python, like slash n or anything else. So it will take this raw string as a whole. Now, I can first of all work on this name, so I will add a second argument. That would be the name of my string variable name. Now any regular expression I write here will be applied on this name string. So what I can do here is I will search for this first director in my name that is age. So to do that I have to write back slash w. What it will do is backslash w will get me this edge here. So I will run this and I will bring this to show you that what we get in the output. So I will write print and we can simply run it again as it is working fine. So as you can see in the output, it says R E match, and then it returns us a object. And then it shows us this span. It is showing us a few details about this object. So from where to where we are getting from 0 index to one. So as we know, indexes start from 0 in a string. So this edge is starting from 0, and then it has given us the upper limit, that is one. And then it is showing us the match, that is h itself. So it is showing us little detail here. So when I hover over this search function here, is, it shows me details about that functions as well if you are interested. So it tells us that what it returns it is return us a match object here as you can see, returning a match object or none if no match was phone. So if there is no match, it will return us none. So how I can just remove himself from here and we can see, as you can see, it returned us none because there was no match for slash w. This slash w is equivalent to this icon first of all right, and then I will explain to Z and 0 to nine and underscore so that slash w is equal to this one, which means cover all the characters from a to Z and capital a to Z as well, and 0 to nine and underscore. So what we have here is these two square brackets surrounding it, which means that it's a set. So anything inside a set is compared and if anything matches there, it will give us that value. So I will run this and as you can see, it gives us none again because our string is empty. Now I will add my name again and I will run it. And you can see again, a gay was an object with the span 0 to one and match it. So how I can manage this complete string now we will see, so this thing was equivalent to slash w. That is easier, so I can just do that, but we will get into the benefits of writing it in a set as well when we come to this long string. So this is slash w, and after this, I can add repetition symbols. So we have a few repetition symbols that is plus asterisk, question mark. So I will start with the plus. So plus gives us anything that is one or many. So it has to be a single character, dear, but it can be any number of characters that can possibly be there. So that is what plus means. So we will look into them, exemple. So I will run this. And as you can see now, Hamza is matched correctly. But if I don't have anything here, what it will do is it will give me none. But if I replace plus sign with asterisk sign, it will return me an object. As you can see, it is returning me an object when I replace plus sign with asterisk and it says from 0 to 0 match an empty string. So asterisk means anything that is 0 or any number of these. So from 0 to any number, and plus sign means 120 number. And if I replace it with a question mark, it will correspond to 01. And it In that can be 0 or one repetitions only 01. So I will run this. And as you can see, it matched because we have, is, we have 0 characters in here, but I will put one character and we will see, as you can see it mashed h. Now, I will add another one. So I will run it. But you can see it only gave me this edge. So why? Because question mark corresponds to 01 here. So I can also explicitly defined some functions that can give me the span and these matches from out of this object. So what I can do here is I can call start. So what starts will do is it will give me the starting index from where the match begins. So as you can see, it's a 0. And then if I replace it with end, it will give me the ending index data is one. So I will add few more correctors here, and we can just simply replace it with asterisks. So as you can see, it says the ending index is five here. And when I write group here, so what it will, group will do is it will give me the match. So that is Hamza. And we can just bring that here. And if I remove this, any function from here, I can just simply print the complete object that I'm getting from there. So in the next session we will work on this long string. So dabs all from this session. 61. Task: Hi there, It's time for your task. So far we have been validated in this email address by using this rejects. Now your task is to make a register that will validate these three email addresses as well. So you can modify this rejects. Do well, he did these three emails as well, including the one we have done before. In the next session, I will give you a solution of it, but give it a try. 62. Solution of Task: Hi there. In this session I will give you a solution of tasks, which I gave you. So I have these three emails, which we have there in task and this e-mail is the one which we were working on. So when I run this program with this email which we have privileged previously done, it works fine. And when I put it to e-mail do it will give us error and so forth. The other as well for three as well, which I have email 3 and e-mail for. So what? We have error on all of these emails now, so we will start by this email to, so what we have different in this e-mail, we have this dollar and then name there. And and that is all. So dollar name is added. So this name string will be covered by slash w. We know that and but this dollar sign will not be covered. So that's why it gives us error in this email to when I run it here. So, okay, to cover this dollar sign, we have to have possibility for special characters as well. I can do that by putting this part backslash w plus in. Instead of doing it like this, I will put it in a set, for example like this. And then I will say it can be backslash w, or it can be dollar sign as well. So now it will be looking for these characters that I have defined in the set. And then plus, which means any number of these. So I will run it. And as you can see, it validated this e-mail to now. Now, I will put email three here, but still it will not validate that because we have something different there. We have this hashtag and name there, and not the domain name is changed to net. So to accommodate this hashtag, what I will do here is I will add it here as well. So I will say it can have hashtag as well. And now, so I will say it can be gone OR operator and it can be met as well. So now when I run it, it will work fine. As you can see, it validated this e-mail as well now because it looks for.net as well. Net as well there. So what I can do for this e-mail for it will again not work on email for because we have this PKA there and this exclamation mark and name. So now I will add that exclamation mark here so to accommodate data as well. And then OR operator and bk. So now it will work for all of these email addresses which I have here. So I will run it and as you can see, it worked for it. And if I change it to e-mail, three again, it will still work. And for email too as well. And for the simple e-mail as well which we have there. So that's how we need to look at what we are expecting the string to be and then modifying our redshifts accordingly and adding different characters there. So that's all from this session. 63. Findall Function: Hi there. In this session we will learn about find all function. So we are using this match function here to validate these e-mails that I have here. So what if I put all these emails in a one screen? So here in this e-mail, I have added all of these email addresses in this single string. Now when I use the match function and give it this email string here, what it will do is it will return me only one single entry that I have. Because it started from the start and found this match here, and it gave me that match and stop there. So what? I want to search all the matches data found in that string. So I need to go through that string and find all. So what I can do here is I can replace it with find all. So now I have this final function. What it returns us is a list that we can use. So now this group function will not be there because we will get a list in this search result and the list will be printed. So there is a point to note about this find all function that it find all the groups if there is any. So we have this group here, comm net and bk. So it will find only these. So rest of the string. It will not give us in the output. So we will have to put that in group or remove all the groups. So there are two possibilities. Either remove all the groups or put everything in group if you want to have complete match there. So first of all, I will run it with this. And we will see the output. As you can see, it gives me all those com and net NPK because that was in a group. So if I remove this group here, so first of all, I will not remove this group and I will put the rest of the part of rejects in group. Now what it will do is it will give me both these groups in the list form. So as you can see in the first part of this, I get two values. That is this one, this part and this part, dad was in separate groups and then I get all this list here. So now what I can do is I can remove this part here, the group here, and the group here as well. So now we have this OR operator that we use previously. I will, I will remove that as well. So that goes there. So now it will search for these matches that I have here. So as you can see, it gave me the first two matches that it found there because there were no groups, so it gives me the complete match here. And then if I change it to net, it will give me the net one. So it give me in a form of a list that this part of it. So that's how we use this findall function. That's all from this session. 64. Finditer Function: Hi there. In this session we will learn about find iter function. So I will replace this find all functions with find ITER. So what it does, it, it returns us a list of objects or which we can integrate. So we will get a list of objects. Now, I will, I have replaced my rejects here so that it covers all of these emails that I have in this long string here. So now what I will receive here, it will be a list. So what I will do is I will iterate over every object that I get in lists. So I will make a for loop for object In search result that I have. What I will do, I will print every object there, so I will make it part of this. And I will say object. So I will run this. And as you can see it give me four objects they are with their span as well. Like first one is from 0 to 16, and this is this one and then 18 to 39. And this one, the same object that we were getting from the search function which we had on here previously. So we are getting all the matches which we have there in a form of a list or which we can iterate. So if I put anything else beside this match, for example, I add my name here. So this is not, this will not be matched by my rejects, so it will ignore that and our output will be same here. So I will run this. As you can see, the part of string that didn't match is not part of this list. That is also true for find all function that we had previously. So if there is anything that is not matched, it will not give us that an output. So that's all from this session. 65. Split Function: Hi there. In this session we will learn about split function. So I have this split function here. Now this function is used when we want to split any string on the basis of anything that we want. So here we can add a register and on the basis of debt rejects, it will split that string. So I have this string, so I will divide, I will split this string on the basis of whitespaces. So for whitespaces, I will add backslash S, and I will run this. And as you can see, it gave me a list with all the words which I have in this screen and divided them. It's splitted them on whitespace. Now what if I want to split it on this Python string? So I will write Phyton here. And now it will give me do values in my list. The first one is my name is I'm the real learning and the second one is to gather, it, splitted this string. And the regex on which we split is not part of our output. For example, Python was part of my regex, so we are splitting the string on Python. Python is not part of my final output. So that's all from this session. 66. Class and Object: Welcome. In this session, we will learn about class and object in object oriented programming. And this concept is very important in object oriented programming. So let's start and we will understand it with the help of an example. Suppose a construction company needs to build a building. So what they need to do first, they cannot go directly at some place and start making that building by joining breaks. So that is not the case. They cannot do that. So what they need to have first, they need to hire an engineer that will make a blueprint of that building. So first of all, we need to have the structure of that building build on paper or something before they can go ahead and make that original building out there. So dad blueprint, which an engineer will make for that building, is called a clause in object-oriented programming. So that blueprint has no real value. It's not something real out there. It's just a structure of that real thing on paper that we call Hebrew blueprint. And now, by using this blueprint, we can go ahead and make an original building out there. Because in Blueprint structure will be defined and everything. So now we can have some people there that can build their building. And that original building is called an object in object oriented programming. And now by using this blue-green, we can have another building out there as well. So now there are two buildings of same blueprint. And we can have a third one as well. And we can have any number of buildings out there by using this blueprint. So this concept is called class and object. Class is basically something you can refer to as a blueprint that defines the structure that how that real thing is going to be. So we need to have glass there. And by using debt glass, we can make as many real objects. Object oriented programming. So object you can think of as something real that has a real value. Klaus is not real glasses something on paper and object is something real. So this concept is called class and object. So by using this glass building, we can have Building a, B, and C out there. And these building a, b, and c will be real, but they will be derived from which class building that will define a structure there. Similarly, a car manufacturing company needs to have a model of car before they can start manufacturing that God. So any company needs to have that engineering model there. So they will hire a person that will make that car model there. And after this, we have that model of Garnier. We can have any number of cars from that model. We can make those cars in February by using debt model, but we need to have that model there. So this model is called class and the real cars, which we will make out of it, are called objects. So everything in real life is a clause. For example, if you have a house, house is a class, and if you have a car, a car is a class, your laptop is a class, your computer is a class. And anything you can think of in real world is a class. Before we can have objects of debt, we need to have something defined for that class. So what class is composed off? It is composed of two things, properties and functions. So what are these? If we have a car class, what will be the properties of car? It's colored top speed, number of wheels, doors. These all will be properties of this car. Anything that refers to how this looks and what discard have will be in properties. And the second thing of glass has, is a function. So what functions God can perform? It can accelerate, it can start, it can Reagan apply break on this and we can stop this car. So any mechanism that any process there discard have any functionality that the scar is have IS, goes in this function part. So class has two things, only two things, properties and functions. You can refer to anything. If you have a building, then it will be properties like color. How many rooms, how many floors and functions will be live? You can open the door, you can close the door and things like that in that building. So everything, every class has properties and functions. Here we have looked at an example of a car, but when we go to an example of book, we can open book that will be function, the color of book will be its property. Number of pages of that book will be its property. So we can define these things in any of our class. So first of all, we have to define a class with the properties and functions. Then we can make any number of objects from that class. Now, let's move into code editor and write some real examples there of class and object. 67. Class Code: Welcome. In this session we will make our first class in good. So I'm in code editor and I will go ahead and make a first-class here. So to make a class we need to use a keyword named glass. So here we have this gloss keyword will be followed by the name of the class that whatever class we are making, we will define the name here. So for example, we are making the person class. Person class can be very important because most of the systems that real-world system like if you have a book Management System, Library Management System or different systems, their person is always required. So if you are, you have a customer, a customer is a person and there are a lot of things that we can do with Person class. So let's understand classes with the help of a person example. Okay, we had this person class. No. One more thing to note here is the class name is always a capital letter, so I'm using B is a capital letter. After the name of the class. We will add this column sign, and then we will move into this class. So now everything written with this indentation in class will be inside of this class. So what class can basically have. So all these properties name, age, gender, and height goes in variable and property section of our class, as you can see in the figure on right. So these are properties. We can put them in property section and we can also add more properties as per our requirement. For now, we have added only these four properties. Now we can also add some functions in this class. So what is function? Function is something that this person can perform, as we know in real-world, what a person can do, person can eat, you can sleep, or he can walk and talk like these things, what a person can actually perform there. So I will go ahead and make a few functions in this class like eat. Eat is a function that a person can perform. So in the body of this function, I will just print eating. Just to make it simple and what other functions we can have. We can also have a function that a person can walk. So we can also print in the body of this function, walking. So a person can walk, he can eat. And now whatever we put in this class, our person class, we'll only have those things in there, not anything else. So if we have added this eat and walk function, then the only thing this class will have it will eat and walk. So we have to implement all of those things that we want in this class. So what is useful functions I can make in this class, like I can make a function that is getName. So what this function getName will do, will return me the name of this person. As an in-person class, I may want to get the name of this person class while I am, because I didn't have a lot of objects of this class like a 100 persons there. I need to get the names of all of those. Like if there is a person Peter, I want to get the name. So getName function, what it will do is it will return mean that is named self dot name. So what I'm doing here is I'm returning just the name of this person. Similarly as getName, I can also get the age of this person. So get age. Get age will return us. So what we are adding self-aware self is something like reference to this class. Self means this person class. So everything that is written self means reference to this particular class person. So when I write self.age, it will give me this age, which I have in this person clause, self-referred to this person. So now we have a few functions like VOC, getName, and get age and discrete function here. Now we can put them in this functions part of our class. So as you can see, all these function goes in function part in the figure on the right. So eat warm, getName and get an image are in this section of functions. Now we have a class which have few properties and a few functions. Now in the next session we will learn about constructor. So that's all from this session. 68. Constructor of Class: Welcome. In this session, we will learn about constructor as we have this person class and it has few properties and functions. We have four functions in this class II to walk, getName and get age. Constructor is also a function, but what is unique about constructor is that it is automatically called when we make an object of this class. So any other function beside constructor is never automatically called. The only function that is automatically called on the object of any class is the constructor. So when we will move into our next session and we will make object of this person class. The only function that will be called automatically will be the constructor of this class. So why do we have constructor? Why do automatically, there is a function that is called automatically. So in that function we can have initial values to our properties. For example, this name, age, gender, and height as they are empty for now and height is 0. But we need to set some default values there. So what we can do here is that while making the object, we can just assign them to default values or we can also get their values from user. So I will go ahead and make a constructor in this class. To make a constructor we use two underscores and then in it, and then after that two underscores as well. This is the constructor of this class. Anytime inside this function will be automatically called when we make the object of person class. So what I can do in the body of this class, I can just move these all properties from here inside of this constructor. So they will be made automatically when we make an object of this class. And what we can do here is we can add self.name because we have to tell that cell does name is of this person class. And we can add it here as well. Self.age, self.age, gender, and self dot height. We need to do when we are making these properties inside the constructor. If we are making them outside this class, outside this function that name, age, gender and height, VGA, not to use this self there because they will be part of this class because we are not defining it in some function. So when we are making them in constructor, we have to add this self because we have to tell that these properties belong to this class. So now what we are doing here is we are making a few properties inside of a constructor. What else we can do here is we can get these properties from user. For example, I want to get the name from the user when, when we are making an object of this person, the person will give us a name for this person and age, gender and height. So what I can do here is I can add name, age, gender, and height. So I have all, all these properties in my arguments now and now, instead of putting it too empty string, what I can do here is I can set it equal to name. So now what I'm saying here is self.name, that is property of this person class. I say set this to the name variable, which I get in the constructor argument. So it will simply put these, this name equal to this name and this edge. We will get it from juicer and I will put it equal to age, gender, and height. So that's, that seems to be wary. I'm good now that we're getting all these things from user so he can send them according to his own requirement that what he wants it to be. So these all things now we will get from user when we will make object in our next session. And then we will set these to these properties automatically. So that's a benefit of constructor that it will automatically be called and it will set these values to a particular properties. So that's all from this session. 69. Object Code: Welcome. In this session we will make object of our person class. So we have our class ready. Now it's time to make an object of this class. And we can now, as we have this blueprint here of this person class, now we can have any number of person objects from this. This class is just a blueprint. That is, it's only defined at Edwards. This person class will have an object will be something real of this class. So we can have person one person to person three and as many persons as we want. So how we can make an object? So I will go ahead and make the first object. First of all, we have to define the name of this object. So if I can just say person with a lowercase b, so it's not a class. It's, it has a lowercase b and I will put it equal to, I have to define the name of this class, that is person. So I will write person with capital P. Now this is the name of the class that is person. After that, I have to provide these four arguments which I have here. If, if I do not have this name, age, gender, and height in this constructor, then I can simply make an object like this that I have to, I have to provide nothing in these two round brackets, but as I have this name, age, gender, and height, because constructor, as we know, is the function that will be called automatically. So what? When I do this, the constructor will be automatically called. And for dad, I have to provide these things which I haven't constructor. So what will be the name of this person? Let's say John is the name of person. And it, as we will want this to be an integer. So I will say 20 years old. After their gender, I will add malate and height. I can say like six. So six feet height is 20 male and named John. So we have a person here that has a name, age, gender, and height. This is a successful initialization of a person object. So we have an object here now named person. We can call these functions like Eat, walk, getName, getAge on this person object. And we can also call these properties there. So I will go ahead and call some function like I have to write the name of the object first of all, and then I can, with this dot operator, I can call any of the things that are inside this class. So as you can see, intellisense is showing me that it has the age function and it has a height eat. Start. As you can see, intellisense is showing me that what this class has, it has age name, height and this method named eat and gender, getAge, getName VOC. So as you can see, we are simply getting that words this class is having after writing this dot operator. So I can select anything from your Eigen, say like get age or walk or eat for, I will call this keyed function on this class. So when I call this Eat function, it should print that it's speeding. So I will go ahead and run this. And as you can see the output it says eating. So what person is successfully made there and object, we have a personal objective and when we call this Eat function on this it says eating know when I can call the warp function on this person object, let's say Person.all. It will call the swap function that is inside our class and it should print they're walking. So as you can see now it prints eating and it also prints forking. So we're calling these functions. We can call any of the functions of this class now as we have the object and every object is unique. So for example, if we have the other object of this person class that will have its unique values. So I will go ahead and print the name of this function. To print the name I would just simply print by writing the name of this person and dot operator. I can also call these variables which I have in this class. So just adding Person.new will give us the name of this person. Now I will go ahead and run this. And as you can see in the output, we have this John printed here. So the name of the person was John, and it printed the names similarly, we can also print age and gender and height of this person object because we have all these properties inside of that glass. So what we are doing here is let's make an, another person here. I will copy this in here and with the few other properties I will make that person. So this will be named person do, and what I can give name here is Peter. Peter is the name and age, let's say 15. Male and height. Let's save five. So we have a second person here now we can also get the name of this person and printed on the screen, Let's say a person, print person to. As you can see, intellisense is telling us that there are two objects person in person too. So I will select person to end dot name. Now we have two persons, that is person one and person two. So person 1 will be having other values like John and person two has a name Peter. So these are two independent objects. We can have any number of objects that we want. So we can have any number of persons here that we want there to be. So we have a person to hear named Peter. Let's run this and we can see in the output, as you can see, it prints Peter here. So specify that this object is different from the first object person which we have there. So it has its own values and an odd place in memory. So we can also call this heat and walk function on this person do as well. And you can call any of the other functions which we have in this class. So one thing you have noticed, as you will, you might have thought that what I'm doing here is that Person.new, I'm getting this property name of this class person by directly writing the object name and then the name of this property. And there is also a function getName that returns this name. So why we have a function here to get the name when we can directly call this name property on an object. So what is the need of making this function getName there? This is of importance, why we are doing this. So why, why we need this function? The reason is there might be some constraints we want to apply on this that names, the number of characters in this name should not be greater than 20. Or we can have any other constraints there. That person name should start with something or we can have different constraint on this, like on age, we can have a constraint that it should not be greater than 100 or 200 because we can have different constraint on these values. And we will learn this in detail when we go to the section named encapsulation. And that is a very important concepts of evil. Get into details of this in our encapsulation part, where we will learn about these things for now, just to show you that we can call any of these functions and any of these properties in this class by directly on the name of that object, we can do that. So I have showed you we have made a person object and the person 2, and we have called these two functions and the property name. Similarly as I've called name, we can call any other property like age, gender, and height on this object. So let's call the age property on this person to support 12 dot h will give us 15. That is eight of this person. So as you can see, it brings 15. Now I can just to specify Eigen add here like person, Peter age, peter edges. And it will then bring the beaters age. After that, I can just simply print John edge. So I will write John images. And I can print John Ridge, person dot h. So now it will print in a more Good former there it says Peter ages 15 and John ages 20. As you can see, they have separate values and separate different all of these class, all of these things which we have in this class are separately available for both of our objects and any number of objects we made. They have that separate team for them. So now as we have this name person here and person 2, we can have an any name of our choice for your object as well. For example, if I want this object to be John instead of like writing person. And so I can do that. I can say John. So what I'm writing here, John. Now John is the object. So as you can see, there is an error line, that person is not there, so I have to write John here as well. So every year we're river using person now I'm using John. So now it will also work in the similar background if it's working before. So we're going to have any name of our object. So that's all from this session. 70. Inheritance: Welcome. In this session, we will learn about inheritance in object oriented programming, and we will learn it with the help of an example. Suppose we have a class named car and it has few properties like color, number of doors. And if you functions like start and stop. And we have another class named Ford, as forward is a GAR, so it will also have all of these properties and functions. So the relation between Ford and God is, is a relation that Ford is a car. So Ford will have all those properties and functions that are inside a car. One way of achieving this, achieving this is debt. We rewrite all the properties and functions that are in car class, in art fold class as well. And the second way of doing it is inheritance. So here inheritance come in play. That by using inheritance, we can simply use all the properties that are in car and all the functions that are in car simply enforced by just using inheritance. Similarly, we have another class name, Honda. It will also have all the properties and functions that are in car because they have is a relation that Honda is a car. So we can simply achieve this by using inheritance. So by this class car, when we use inheritance and inherit these two classes, Ford and harder, all the properties and functions in our car class will automatically be added in our fourth class and Honda clause. So that is benefit of inheritance that we need not to rewrite all of these things there in these glasses today are simply present in these both glasses. So when we inherit other classes from a parent class, that is the car class we have inherited three Clouds, Ford, Honda, and Toyota. We can also inherit other classes from this class car. So the top loss from where we inherit other classes is called parent loss. And all the inherited classes are called giant classes. They have another name as well. Parent class can also be called as base class and child classes can also be called as Dr. classes. So all the properties and functions that are in car class will be separately edit to all inherited classes. That is, the fourth glass will be having gone class functionality. And in addition to dead, it will have other functionality that is specific to fold. Similarly, Honda class will have called glass functionality. And in addition to that other functionality specific to Honda. Similarly data's case with Toyota data, it will have core functionality on the things of God clause. And in addition to that, it will have other functionality specific to Toyota that has benefit of inheritance that we get all the properties and functions from parent class in giant classes. And then we can have other functionality related to those giant classes as well. Because Ford, Honda, and Toyota or different companies. So they will be having some specific properties to their brand as well. So that will be added to these glasses. So this is the benefit of object oriented programming, that data reusability. Suppose we have a base class that has 20 properties and 100 functions. Now if you want to add all these properties and functions to some other clause, we need not to rewrite them. We can simply inherit debt class from this base class and it will become a drive class and it will have all those properties and functions inside that class. And in addition to that, it can have other properties and functions that are specific to that Dr class. So this is a great benefit of inheritance, that is data reusability. We can reuse data from our base class into our drive class without writing and repeating that code again and again. So that's all from this session. 71. Inheritance Code: Welcome. In this session, we will learn about inheritance. Inheritance is very important in object oriented programming. So we have a className person here and we can inherit other classes from this person class. And to have inheritance we need to have is a relation. That is, we can have other classes like student, teacher, employee, and many more that are like student is a person, teacher is a person, employee is a person. So whatever we have, whenever we have it is a relationship. We can inherit those classes from this person class. So let's make it another class that is student. Now we have a Student class and how we can inherited, we need to have to round brackets here inside these two wrong records, we will write the name of dead class from which this class will inherit. So I write person here. Now what we are seeing by writing this is we have another gloss student, and it inherits from this person class. So the student class already has all these things which are in-person class. No, we need not to rewrite this or really not to duplicate this code. So that is the benefit of inheritance debt. Because we know that student can eat, student can also walk. Students have in name, age and Fahrenheit. These all things also belong to students as they belong to person. So students can have all these things in real life. When we, when we, when we think of debts to what students can have, students can have all these things because student is a person. So we have all these things already in this class student, this is very beneficial when we have big classes that we want to reuse. We can simply inherited them in other classes. So I will go ahead and add a few other things in the student class because the student class will have some specific things to student as well. So all of these things are already inside, but we can, on top of this, we can have other properties and functions. So what things that are specific to students we can have in this class, like student can have it rolled number. Students can have a roll number like initially I will put it equal to 0 because it will be integer thing. Because as he is a student, he will be having a row number that the person Specific cannot have. So students can have an old number because he is a student's student can have marks. I will initially put it equal to a 100, let say default value. So students can have marks on top of what we have in person class that are only specific to students. Now these can be the properties and we can have any number of properties and more properties here as we want. Now I can make a function here like students can attend class, student can take class. So I will have a function name, date class. So this function is specific to students that students can take class, that you can attend class. So what I will write in this body of this function, I will say taking class. So now we have one more function in the student class that is on top of these all other functions which we have there. So this class takes, this takes class function. Now when we will make objects of the student class, all of these things, I can assess all these things which are heavier in these both losses. So let's go ahead and make the object here, like student with small S equal to student. Now, we can provide all of these name, age, gender, and height because this constructor is in-person class. But we have also, this is available in the student class. So what I can do here is I can write name, for example, I right, Hamza. And what is the age? Age, I can say. It will be an integer, so I can say 25. And then I can write like gender, male. After that height, I can write like, let's say six. So we have a student name Holmes, average age 25, gender, male and height six feet, six feet. So now we can call these functions on dislike writing the name of the object, student dot. Now when I write a dot operator, as you can see, it shows me that what I can call on this object, Call age name, walkie talkie, gender. And all the it is showing me all these functions and properties that are in person class. And on top of that, as you can see here, marks and rule number is also there. So these marks and row number or in the student class, but they are not in-person class. So I can also call this thing, these things here. So let's call some functions from this person class like eat. When I call this function, eat as it is in-person class and it is also available in students. So it should call this function eat. So I will go ahead and run this. As you can see, it says eating. So I have this specific function in the student class. Now I can call this function to date class student dot tip loss. Now take losses in the student class. So it should also call that, as you can see, it says taking gloss. So dad has benefit of inheritance. I can call all these functions, all these properties and methods on the student class. But when I make a person class object, I can only call these things that are in person class. I cannot call the student related things in person class because student inherits from person, person doesn't inherit from students saw in student, I have these other things, but in person class, I have only these things which I have already there. So in Student class I can call all of these things. So this adds to the person class bike and have other classes like teacher employ as well depending upon our requirement that word system we are building there. So in this session we have learned about inheritance. That's all from this session. 72. Abstraction Code: Welcome. In this session, we will learn about abstraction. We have previously made these three classes, shape, rectangle and triangle. And all of these have this function named area that is calculating area of the respective class. For example, rectangle class has the area function that calculates area for rectangle. And triangle class has an area function that calculates area for triangle. Now, if we make this class public and other people can use this by making your subject. What they will do here is they will make the object and call this area function on their objects. Now the person who is calling this area function on the object is unaware of how we are achieving this area. They are heavier calculating it. So we are hiding this internal detail from outside world. So people are unaware that how we are calculating this area. So now here, when a person calls it rectangle.js area, he is only concerned with the results. Here. He is creating an object here with the values and now he wants the area as long as debt areas calculated correctly. He has no concerns with the internal functionality that how we are calculating and achieving these results. Similarly with the case of triangle, when a person makes a triangle object and it calls an area function on triangle, as long as the reserves are correct, they are not concerned with internal functionality. So we are hiding this internal functionality here. Both of these area functions that how we are calculating this, we are using this width and height variable. Debt can be of some other name as well. We may, we may use W and edge here instead of width and height. So the person who is making object is not concerned with dad. By doing this, we are hiding this internal details from user. So this is called abstraction that we are only showing those functions to user, the name of function to user that he can use to achieve his target. As area is a name of function that the user only needs to know. To calculate area. He should, he should be unaware of this internal functionality. So this is called abstraction, and this is a very useful concept. Suppose we have a class mat and there is a function named factorial in that. So to calculate factorial, we may be using any type of code. We will be using a few steps to calculate factorial, but user need not to know about those. Similarly in the case of car, if you have an acceleration function, user needs not to know about acceleration function details. The only thing you need to know about is acceleration function name. So another benefit of this is that while we are only giving the name of the function and the V matrix dysfunctionality afterwards and debt will not make any changes on user side. For example, initially we gave this class to public that they can make its objects and use it. And later on, there are a lot of people use this function area by making the object of this. Now, we later on decided after few years that we will be calculating area with some different functionality. So we change the code inside of this function. Now on our side, there are changes, but on user side there is no change because they were calling this area function. And still they are calling this area function as long as we do not change the name of this function. So area function has same name but with different functionality. We can change the functionality later on. We can achieve results by using some other algorithm or something like this is an example of area. But there, you can think of Bitcoin is where we have complicated functionalities. Suppose we have an algorithm for sorting, and later on after few years we have a better algorithm for sorting. So what we need to do, we need to simply change the code inside of that function. And on user side, the person who is using it, there are no changes because they are using these names, area, and any other name of that function that we are giving in our class. So that is a benefit of abstraction that we hired internal details from outside world. So that's all from this session. 73. Polymorphism: Welcome. In this session we will learn about polymorphism. Polymorphism is a very important concept in object oriented programming. Polymorphism can be divided into two parts, poorly and morphism. Boldly refers to many and morphism refers to forms. So polymorphism completely refers to many forms. So let's learn it with the help of an example. Suppose we have a class name shape. It can have a few properties like sides of dark shape, area of their shapes and angles between the sides of that shape. And this shape can be of different type like triangle, rectangle, square, and so on. So shape is our base class and all the rest of these classes are derived classes. So triangle has three sides and rectangle has four. So all of these have these properties with different values. But when it comes to calculating the area of all of these shapes, the formula for calculating area is different for every shape. That is, triangle cannot have same function for calculating area. And they have different formulas. So if we have a base class name shape and it has a function named calculate area, it might have some functionality, but when it comes to triangle, that is giant class, Dr class, it has different formula for calculating area. And so square has an rectangle as well. They all have different formula for calculating their area. Now what we have concept of base and derived class, if we have a calculate area function in our base class. So the drive class automatically has that function. That is our concept of inheritance. So if we have a shape class as a base and it has calculate area function, then the rectangle class that is derived class will automatically be having this function there. But when we go ahead and redefine that function, so what we are doing here, we are redefining their function in our derived class because rectangle has a different formula for calculating area. So we cannot use that same function of base class. So this concept is called overriding the function that we are redefining, calculate area function in our derived class with a different functionality. Now, it will ignore that function in base class and it will use the function of Dr. class. So base class function will never be called and it will only call drought class function calculate area. Dad makes a lot of sense for rectangle. It will call rectangle area function and for triangle, the different function in triangle. So this concept refers to polymorphism. That is many forms. We can have many forms of same function. Calculate area is a function that is redefined and drive class. So it has different forms, like for rectangle, it has different calculate area for a triangle, different for heads-up on different, for circle different. It has many farms. So this concept refers to polymorphism. This can also apply in other classes. Suppose we have a class named car, then different cars can have a lot of different functions. They are like starting mechanism. For example, different cars have different starting mechanism. Some cards are started by the key, some width button, and some with different options there. So we can not have a starting mechanism function for every car. Same, we need to have different functions there. And similarly with the acceleration function, if we have an acceleration function, different cars might have different time and different process and different mechanism of acceleration. And same is the case for breaks. Different cars have different mechanism of braking system. So we have polymorphism concept here in object oriented programming. So now let's understand it in Good. 74. Polymorphism Code: Welcome. In this session we will learn about polymorphism. So I'm in code editor and we will understand it with the help of an example. So first of all, I will go ahead and make a class name shape. So we have a class named shape and it will be parent class, and we will drive a few classes from this class. In this class, I will make two variables. The first one will be weighted and I will initialize it with 0, and the second one will be height. And I will also initialize it with 0. After this, I will have a function named area in this class. So area. And I will print on screen that this is patron class area. So I will go ahead and make an another class hero named rectangle. This class will be inherited from our shape class. So I will have rectangle class, and it will inherit from our shape class. I will have a constructor in this class that will initialize these values width and height with the values that user provide us. So let's make a constructor here. And in this constructor, I will get two values, W for width and h for height. So I will do self.view. I will put it equal to w, that will be the value from user. And next, self.init equals to h height. So rectangle is our derived class. Now I will go ahead and make an object of this rectangle class. So rectangle with lowercase r is our object and I will put it equal to rectangle. Now we have to provide two values here because we have to set the width and height. I will say 10 and 20. So these are the two values. Now, I will call this area function on my rectangle object. So rectangle.js area. As we no doubt due to inheritance, all these properties and functions are already inside of our rectangle class. So rectangle class has dysfunction named area due to inheritance. I will go ahead and run this and we will see in the output, as you can see, it says parent class area. So it printed this value parent class area, which was in shapeless and it was inherited in rectangle class. Now, what we need to do here is the rectangle class has a different formula for calculating area. So we cannot use this parent class area, which says parent class area here. So what I will do here is I will redefine this function in my rectangle class. And this is called overriding a function because we know that due to inheritance, this function was already in a rectangle class. But what I'm going to do here is I'm going to define it again. So area in the body of this function I can print area of rectangle is now this will print the area of rectangle for debt. We have to calculate it and how we can calculate its width into height will give us the area of this rectangle. So I will just perform that here. Dot width, do self dot height. So by multiplying these two values, I will get area of rectangle. So it will print this one here. Now, I will go ahead and run this again. As you can see now it says area of rectangle is 200, that is ten into 20. So it has ignored this function for our rectangle class. It has not called the parent class function. So why is that? Because we are overriding this function, we are defining it again. This is called overriding a function. The function area was already in base class, but we redefined it. We over, overridden. We have overridden this function here depending upon our requirement. So now I will go ahead and make an another class named triangle. It will also be inherited from our shape class. So we have a triangle class here. I will just copy this constructor here because it will also be setting these values for width and height. After that, I will again override dysfunction area in this class as well. So area, and I will save print. It will say area of triangle is. Now we're going to print the area of triangles when we have to apply formula for triangle. And that is base into height divided by two. So we will take width at it as a base and height has a height of triangle. So what I will do, I will write a formula that self dot width into height. So now here, which is the base of our triangle and height is height and I will do via it. First of all, it will multiply these two values and then I will divide it by two. So this will give us the area of triangle. Now we have two glosses, rectangle and triangle debtor inherited from our shape class. So now I will make an object of triangle gloss. Triangle is a triangle. Now I have to provide these two values. And that can be offered choice Lexi two and 10. So base is two and height is 10. Now, I will also print area of triangle. So triangle area. Now it is not supposed to call this shaped glass area function, and it is supposed to call this area function which we have in triangle. So we have overridden this area function in R, both classes, rectangle and triangle dependent upon the requirement because rectangle has different method for calculating area and triangle has different. So I will run this again and we will see in the output, as you can see, it says area of rectangle is 280 of triangles, 10 as it multiplied ten with two, that is 20, and then divided it by two, so it gave us 10. So this is how polymorphism is done. That depending upon our requirement, we override the function of our base class. Suppose if you have a car class, they are and we drive two classes from it, that is Honda and Toyota. So they have different method of acceleration, like they can not have same acceleration type. So there needs to be something different in both the functions of acceleration for our other classes. So this concept is very important polymorphism that we have different forms of this function area in our drive clauses. And we can have it in different other classes as well. So this is of course important in object-oriented programming. So that's all from this session.