Syntax, Comments, and Variables

 Syntax, Comments, and Variables

Guys welcome again to my latest Tutorial. Although it is completely understood what we are going to learn in the lesson, let's be specific
→ We would be reading how to write syntax, Indentation, how to store values in Variables, creating them, and how to write comments.
So, without further ado, let's start 👉



Syntax

So, Syntax is the set of rules that defines how a Python program will be written.
In the earlier lesson, we learned how to execute a Syntax in IDLE(script and Interactive Mode) or CMD.




Indentation

So, pay attention here. This is one of the most important topics.

So, what is Indentation??
Indentation refers to the spaces at the beginning of a block of code.
It is used to indicate a block of code IN PYTHON, while in other languages, it is used for readability.

For example ⇒


(Don't Worry, I will explain Conditional Statements in my upcoming tutorials)

You will find here that before the print function, I have left some spaces(usually 4); this is because the whole If...Else is a block of code, and to indicate it as a separate block, I have to indent it or else it will show us an error →


See, It says IndentationError: expected an indented block.
So, now Indentation is complete.

Comments

As the name suggests, it is used for commenting, which can be used for explaining a code and for good readability. The thing is that Python ignores comments and doesn't execute them. Check This ↴


Variables

So now, Variables, as we all have studied in Maths, It is used to store values and can take on different values depending upon the user.

Creating Variables

So in Python, there is no option for declaring variables, so you can simply create them.
As soon as a variable is given a value, It is created.
See ↴


So here, I have created three variables → x, y and, z
  • x is storing the string or a set of alphabets that is "Hi from x. But it is a string so that's why I have used double-quotes.
  • y is storing the integer 10, but it doesn't need a double-quote because it is not a String.
  • z is storing the float or decimal number 10.5 but it also doesn't need a double-quote.
So, that's all for today. The next tutorial is going to be a bit lengthy, but an interesting one.
Till Then Bye 👋

End Of Tutorial.....

Hope you liked this tutorial.

Don't forget to Follow, Like, and Comment on my Social Pages ➤ Twitter ➤ Instagram ➤ Facebook

Thanks,

Dheeraj


Comments