First Steps

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:

Python

However, there are certain restrictions.

A variable name cannot start with a number. Let's see what happens if we try:

Python
Output

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.

Python
Output

What will be the output?

Python

What will be the output?

Python

Another important aspect of the Python syntax is indentation.

Indentation refers to the whitespace at the beginning of a code line.

Python

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:

Python
Output

What will be the output?

Python