Runtime and Compile Time

Please explain compile-time and runtime with an example.

Hello @merajzafir,
Compile-time means we will convert all of the code into some binary source code and then run that and if any of the compilation error or syntactical error is there, the whole code won’t run.
Runtime means we will run the code line by line, and if any error comes up while running the code, it stops there only but executes everything before that error.

So, python’s cool thing is that it tells about the errors at runtime and executes everything before the error.
For an, e.g.,

print('Hello World')
print('Hello Again')
print(10/0)

# Hello World
# Hello Again
# Error will be there, division by zero or modulo by zero

So here it executed everything before the error.

Now, some of the popular languages such as C++ or Java, are compile-time, they first of all check if there is an error or not and then it executes the code.

I hope both it is clear to you, if there is any confusion pls let me know.
Please mark it as resolve and feel free to provide the feedback if it is clear to you.
Thanks :slight_smile:

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.