Coding Example of variables

Lesson Details:
September 17, 2020

Video Transcription: In this lecture we are going to have an example that will show you how to declare and use variables this video is brought to you by Appy Pie’s Academy, now this is the project hello mahajan that we people have used in the previous example i will press the right mouse button on it go to new and then choose python file always remember in one project you can have as many python files as you want now give it a name i am going to give it the name like suppose uh my variables okay so i'm going to click on ok so let me write this program now i am writing my name is equal to within quotation marks anand so that means my name is a variable and its value has been assigned full value has been assigned as anand mahajan so second variable is city i am going to assign it the value kurukshetra as both the variables are containing the values which were written within double quotes they are string variables the third one is also string variable i would write country is equal to india within quotation marks so in total i have got three variables although three variables they happen to be of string data type so now i am going to use print in order to show the output on the screen so what i am doing is i am writing i am within double inverted commas then plus concatenation symbol my name then again plus slash n is going to take the control to the next line that is newline i live in will be printed as it is plus concatenation symbol and city plus is the concatenation symbol that joins two items together so again i am writing print my country is within quotation marks plus country name of the variable is country so again have a look at the program my name is a variable which is being assigned the value on margins it is the variable which is being assigned the value kurukshetra and country is another third variable which is containing the value india so in print statement what i am doing is within double quotes i am writing i am and one space so it will be printed as it is plus is the concatenation symbol that will join the two items uh here two items means i am constant and my name variable so value of my name variable is anand mahachan so it will be i am anand mahajan again plus concatenation symbol and in continuation within double quotes i am going to write slash n that will take the control to the next line i live in will be printed as it is then concatenation symbol plus then city so the value of city is kurukshetra so though so the output would be i am mahajan i live in kurukshetra now in the next print same thing is going to happen my country is will be printed as it is and plus concatenation symbol will concatenate with it the value of the variable country and as you know the value of the variable country is india so we have completed this program now let's go to run and then i will click on the name of the program uh oops i think i have chosen the wrong name of the program okay let's go back to run so i have chosen the program variables dot p y p y is the extension given to the python programs actually i had deleted this program and this was just a sample program so because the name of the program was not variables but my variables so again i will go to run then i will click on run i will choose the correct name of the program that is my variables i will click on it okay now see there is an error and the error is bad operand type for unreal plus actually uh i have given the plus symbol in the first print statement uh this is redundant in the beginning of this print statement this plus symbol is redundant it was uh an error to give it here because nothing was going to be concatenated here again run the program choose my variables okay so this is our output let me show you the full output i am anand mahajan i live in kurukshetra and my country is india so the output is being displayed. 


loader
Course content