Python Syntax Basics
Learn some Python syntax basics
We have already learnt that you can name a variable as you wish.
These are all valid variable names:
However, there are certain restrictions.
A variable name cannot start with a number. Let's see what happens if we try:
Python will also not accept any special characters like .-+:,;()/#*'"?
in your variable names. They are reserved for other functionalities.
Also, be aware that variable names are case sentive.
The following are 2 different variables.
What will be the output?
What will be the output?
Another important aspect of the Python syntax is indentation.
Indentation refers to the whitespace at the beginning of a code line.
Your Python program will throw an error if it encounters unexpected whitespace at the beginning of a code line. Let's see what happens if we use unnecessary indentation:
What will be the output?