Python Tutorial for Beginners

It’s Python compiled or integrated language to save you a few minutes the answer is straightforward which is both so python is compiled as well as interpreted language but hold on when you read some books or when you see some articles on the internet, therefore, python as an interpreted language why so and why I’m saying is both let’s find out in this video welcome back aliens my name is 720 and let’s see one is both compiled and interpret language so first let’s find out what is a compiler or when do you say a language is a compiled language so think about this programming languages right we have so many programming languages like we have seen we have C++ Python Java now when it comes to C and C++ they are compiled languages right because you as a programmer you write a C program right here is C code now this is the high-level languages which simply means your machine cannot understand.

These languages because by default computer works only on machine language which is whether you format basically so that means when you write a code which is in C language you have to convert that code into a machine language and that’s where compiler comes to the picture so your C code gets compiled to give you the machine code the same goes for another language as well so that’s why we say it’s a compiled language now compiler doesn’t just have a way of converting a high-level language into machine language sometimes you also convert a language from A to B now a can many language and B can many languages provided there’s a way to convert that so a compiler can convert any language from any language so you cannot simply say from high to low it can be from high to high as well that’s the basic term which we use compiler right.

So basically when you work with Python we have a different way of working the moment you work with a Python file its first gets compiled you heard me write it first gets compiled to give you a bytecode okay and that bytecode will be interpreted in a machine language and who does that it’s the special virtual machine but hold on why so complex process so what exactly this interpreted means so basically interpreted languages simply means you have a set of instructions and here the interpreter will read each and every line one by one so line 1 line 2 line 3 line 4 95 and it will start executing everything line by line and that’s why it is called interpreted language so now what happens is your bytecode is interpreted by then why we have to make it so complex of having comparison first and then going for interpretation for one reason.

We use a concept of bytecode to achieve portability right now what is particular to here so we have this term right which is platform independence that you can write code once and you can run on different platform example as your machine changes your CPU architecture also changes right so if you’re reading a quote for one machine and if you compiling it to get a binary file or a native code it may not work on some other machines because machine may have a different CPU architecture and to solve this problem we have a concept of virtual machine now in this virtual machine what you run is a bytecode ok and this bytecode will run on that virtual machine and that will convert into native code that simply means any machine or doesn’t matter what’s your cpu architecture using so if your machine has a vm software or the virtual machine software you’re good to go the moment I say virtual machine are you thinking about VMware or something not exactly we are not trying to copy a physical Hardware so this washer machine which I’m talking about is race specific to the languages example for Python we have a VM the same concept is there in Java as well which is a JVM so we have virtual machine in Java which is JVM and for Python we use PBM of course right on JVM we can run other language as well like Scala groovy Cortland but on DVM we can run Python codes so basically.

You write a Python code which gets compiled which is the bytecode and that bytecode will be interpreted on your p VM to give you the actual output then the question arises when you are running Python you never did that because if you are coming from a Java background by any chance in Java we have this concept right so first you have to compile the code by letting Java C and then you have to run the file using Java command in Python we don’t do that right we simply say turn and then we mentioned the filename we are not doing combinations right and that’s the beauty of Python Python says hey programmer you don’t have to worry about compilation I will take it up that you simply say Python and the file name I will compile it I will give you byte code and then that bytecode will run on your ppm okay what about interactive shells so normally when.

This image has an empty alt attribute; its file name is mobile-phone-1513945_1920-1024x763.jpg

We use rebels so we title comment to the commands right they simply say print hello is it creating Pikeville as well yes so behind the scene whatever you do and Python it creates a byte code first and that byte could catch one on ppm so the premium is very important in terms of let’s say if you want to do performance tuning later if you want to understand how exactly everything is working behind the scene so there is one more thing which we have to address here and which is C Python oh that’s weird right what is the C Python what if I say whatever we have learned in the Python series everything was about C Python right but we have never mentioned that because normally we always talk about Python language right we never talk about the implementation what if I say python is just a language set of rules and conventions the actual implementation which

We are using here is c python okay so whatever we have learned is actually C Python we have some other implementation as well for Python so you can imagine Python is a point set and then we have other implementations example you know if you want to eat any taste let’s say if you want to eat dosa so we have a constant in mind right so this is how dosa looks like but then if you go to different restaurants they have a different way of serving it and now we have different versions of those are available in the same way for Python is a language and then we have different implementation we have C Python we have pi PI and then we also have an eye on Python and then we have Jade on so basically.

You know when you talk about C Python it is implemented in C language so the internal working is happening with C language on the other hand when you say Jade on which is Java somewhere with Java right so the implementation is done using Java language and then we have the dotnet version of it which is IronPython which is the dot implementation of it so there is one language and we have different implementations so in general, the widely used implementation is C Python but I would also suggest you to have a look on this other stuff as well so just to give you a summary whatever we have discussed till now what is Python it’s a compiled and interpreted language okay so even if you are not compiling it behind the scene it’s happening so behind the scene it is getting compiled.

Leave a Comment