Transcript for:
Introduction to Python Programming Fundamentals

hey guys what's up my name is vice vedi and welcome back to my channel all about python guys this is the first video of class 11 computer science python course where i am going to talk about class 11 chapter 5 getting started with python guys before i start this video i have a small announcement you must know that there are many chapters in ncert that do not talk about python since this channel is devoted to python i am going to cover only those chapters for now that talk something related to python but if you like my teaching methods and want me to cover each and every chapter of class 11th and 12th computer science in cert don't forget to subscribe to my channel and mention your thoughts in the comment section below with this let's start with class 11th chapter 5 getting started with python as you all must have seen from the video's description i have created notes of nc ert chapters like the one you are viewing right now i have created these notes using the ncert book and my personal experience in programming and have kept them short but up to the point so that you won't waste much of your time reading them you can download and use these notes by checking out my blog site link is in the description down below so let's start with introduction to python first we will talk about program now a program can be understood as a set of tasks that a computer has to perform in a specific order to perform an action let me give you a quick real life example for that let's say your mother wants you to bring a glass of water for her when she tells you to do so she is in a way executing a program where you are the computer and bringing glass of water is a program now you will perform a set of tasks to complete this action like going to the water cooler getting an empty glass filling the glass with water and bringing the glass to your mother just like this example a program also performs set of tasks to complete an action also just like your mother would have taught you once in your lifetime how to bring a glass of water and then would have instructed you to do it programmers also tell a computer how to perform an action and then the computer performs it every time it is told to do so they do this by making programs and that's what programmers do they make programs i hope that gives you an idea as to what a program is in case if you didn't understand don't worry you will get it as we progress through the chapters now let's talk about programming language coming back to the previous example your mother would tell you to bring a glass of water by speaking to you in a language she is able to tell you the command because there is a language that both you and mother understand similarly we need the language that both you and computer would understand so that you can tell the computer what program you want to make or execute this language is what we call programming language there are many programming languages that currently exist some of them are c c plus plus c sharp java python pearl etc from exam point of view i would suggest you you must know names of few of them as it may come in exam now let's talk about how python works as you all must be aware of computers only understand the language of zeros and ones which means they cannot understand our language so the question arises then how come a programming language like python work well the answer is simple it acts like a translator when we write our instructions in a specific language they are eventually converted to machine language i am not going to go in depth about how it works but it requires us one of these two softwares compiler or interpreter python specifically uses interpreter to convert programming language code to machine language code an interpreter goes line by line through the script by the way script is the file which contains our code and as it goes line by line firstly it checks whether a line of code is correctly written based on the programming language we are using and then it executes the code and moves on to the next line in case if the line of code is wrong it would give us an error and the program stops right away in other words there are two ways in which a program can stop number one when it finds an error and number two when the whole code is executed successfully i hope it's clear to you all now that we know how python works let's talk about the features of python number one high level language open source and free to use let me explain these words to you all high-level programming languages are those programming languages that are more human understandable in other words we can say the keywords used within the programming language are created using english language making it more easy for us to understand and use python is also a high level language which makes it easier for us to understand and use next word is open source open source programs or softwares are those programs whose source code or the actual code running behind the program is freely available for public to view and use if you are a good programmer you can even contribute to open source by suggesting and making changes in the source code with prior permission of program developers python is also open source and its code can be viewed on github you can search for python github on google and you will find it let's move to the next feature interpreter language well there is nothing much to understand here as i have already told you that python uses interpreter to convert its code to machine language making it an interpreter language next feature is easy to understand have clear and simple structure one of the features that makes python more popular and useful compared to other languages is this python has a very simpler and clearer syntax compared to other most popular programming languages this is one more reason you all are being taught programming using python and this is also the reason why i personally love this programming language okay next point is python is case sensitive it simply means that for python interpreter number in capital and number in small are two different things basically it considers the case of the characters while analyzing the code those of you who have ever quoted in html would understand how html is non-case sensitive next we have python is platform independent this means that python can work on multiple operating systems be it the common windows the rich people's mac os or the developers linux python works in all of them it would also work on different hardware architectures like x64 x86 etc next we have python has a variety of library of predefined functions python has a ton of libraries be it built-in or be it like other modules this helps developers a lot as they can perform quite difficult and long task by just importing a module in case if you don't understand what i mean don't worry you will get it as we will go through future chapters the next feature is that python is very useful in web development python is also very famous for its use in web development many popular sites like youtube facebook instagram bittorrent spotify etc are made in python many web developers that use python work at it herbs at google facebook amazon etc and the last feature that we have is that python uses indentation for blocks this is also something that makes python so different from rest of the programming languages python does not use braces like most other programming languages do instead it uses indentations i will show this in the later chapters again from exam point of view i would suggest you memorize these points and understand each of them as it can definitely be asked in your exams now that we are well versed with the features of python it's time for our first practical now i will show you a quick demo of using python and tell you more about idle before i start the demo i am assuming you have python downloaded in your system in case if it's not check out my video on how to download and install python within 5 minutes [Music] ok guys now that we have python downloaded and installed we will start by opening idle just search for idle on your system and you will find it idli stands for integrated desktop and learning environment it's a built-in python ide that comes pre-installed with python once your idli is open you can start by typing print bracket open double quotes hello all about python double quotes bracket close like this when you type this and hit enter a message will be displayed saying hello all about python remember how i told you python interpreter goes line by line and executes it that's exactly what is happening here python processed our line of code found that it is correct by syntax and then executed the code to give us the output simple right this mode of idle is called interactive mode here we can run single line of python code to test what the code can do this will be really useful for you when you will learn about python functions you can also use this mode as a calculator let's type 12 plus 23 and hit enter as you can see it gave us the output 35 now let's click on file and click on new file this will open a new file now type print bracket open double quote hello there double quote bracket close and on the next line type print bracket open double quote this is which is speaking from all about python you can also write anything different just write it down between the double quotes and after you double quotes just close the bracket once you have written this we will click on file save as then we will give the file a name and save it somewhere i will save it in the desktop once saved we will click in run run module as you can see it gave us the output hello there this is we say speaking from all about python if you had written something else your output will be a bit different what we did here is that instead of using interactive mode to type lines of code one by one we created a python script and typed all our python lines of code and random together as a single script this time python interpreter ran all the lines within the script one by one this mode is called script mode this is where you will make programs and code most of your time you will write all the lines of code to perform a certain task and later when you execute the script all the lines will be executed now that you know about idli let's come back to python and talk about python keywords keywords in python are some words that have specific meaning and purpose according to python interpreter just like every person in your family has a name and a certain role to play within the family python also has keywords that have certain meaning and work to do to get a list of keywords open your idle and type help and hit enter this opens the help menu now type keywords the words that you see are the key words present within python each of these words have meaning and purpose we will talk about these words later in future chapters next comes identifiers if you talk about people outside your family like your friends or teacher or all other persons they all have names which give them the identity right similarly we need to give any data within the python code like a string or a number or anything else an identity through which python interpreter could uniquely identify it we use what programmers call identifiers like first name equals to which is channel name equals to all about python in this example first name and channel name are the identifiers that are used to give unique identity to two different strings which says and all about python in other words python now knows that when you say first name you mean visays and when you say channel name you mean all about python pretty simple right now there are some rules which you must follow while creating identifiers in python number one name should only start with any alphabet or underscore for example name or capital name or underscore name is acceptable but not name or two name is incorrect number two it cannot be one of the python reserved keywords the one which we discussed before this topic and number three you cannot use any special characters except underscore anywhere in the identifier again these points are important from exam point of view as questions may come where they would give you identify names and ask you whether these identifiers are valid or not next let's talk about variables coming back to the last example first name equals to which is channel name equals to all about python we know that first name and channel names are identifiers but they are not just identifiers in terms of programming these words are also in a way storing data in them first name stores a string we says and channel name stores a string all about python that's what we say that identifiers when they store some data are called variables there are some points regarding variables number one variables can store any form of data be it string integer objects etc number two data stored in variable is temporary which means that variables exist as long as program is running once program execution stops the variable is removed from memory you can give a variable name change its value and retrieve its value during program execution here is a quick demo of python variables in this demo we will create our first python program for this we will first create three variables channel name whose value will be all about python price whose value will be 123 and gender whose value will be capital m first we will try to print channel name first we will just print the channel name is and in the next line we will write print statement and in under the brackets we will write the name of the variable which is channel name as you will see that when we write this it will actually print the value of channel name that is it will print all about python okay this is the first way you can write or display the value of a variable in python next we will write print the price is comma followed by price now this is another way in which you can write the value of a variable in python in this way we are actually writing the value of variable on the same line along with some other sentence if we run this we will actually get the price is 123.4 on the same line so that's how it works and let's go on the next example now what we will do is that we will change the value of variable gender to male earlier its value was m now it will be male now if we print the value of gender you will find that the value printed would be male that is because before we could print its value we changed its value so the value of gender will be printed that will be printed would be the latest value which is male that is why the gender came out to be male now let's talk about python comments when you will write long lines of code for a complex program you can get confused between the hundreds of lines and thousands of words this is a difficulty many programmers face who don't use comments comments aligns with any code that are skipped by the python interpreter that is python interpreter will simply skip these lines and will not execute or treat them as python code programmers use comments between their script lines to make the code more simple and easy to understand in future like they would write a comment telling what is the use of a specific variable which they have assigned within the code let's quickly go over a demo on comments [Music] there are two types of comments that python supports number one single line comment which is used to write a comment of a single line hashtag is used to create single line comment number two multi-line comment which is used to write comments of more than one line three single quotes or three double quotes are used to create multi-lined comments as you can see here i have written four print statements but only one of them will run and that is this one the other three print statements will not be executed by patter interpreter because this print statement is on a completely new line starting with hashtag making this a single line comment if we check about this print statement this print statement is already on a line which has another print statement which is correct but this print statement also is written after a hashtag which also makes this a comment and if we talk about this print statement this print statement is written between single quotes making it a multi-line comment and as we know that comments are not read or executed by python interpreter these three print statements will not be executed and only this print statement will be executed and if we run it and we will see that only that printed statement has given us the output and none other statement has that's all we are going to cover in this chapter for now thank you for watching i will cover further of this chapter in the upcoming video so subscribe to the channel click on bell icon so that you get to know when i post a new video [Music] you