Python Syntax
Python Syntax
Output:
SyntaxError: EOL while scanning string literal
Python Multiline Statements
We saw that Python does not mandate semicolons.
A new line means a new statement.
want to split a statement over two or more lines.
It may be to aid readability.
can do so in the following ways
You can indent using a number of tabs or spaces, or a combination of those. But remember,
indent statements under one block of code with the same amount of tabs and spaces.
Python Multiple Statements in One Line
You can also fit in more than one statement on one line.
Do this by separating them with a semicolon.
Python Quotations
Python supports the single quote and the double quote for string literals
But if you begin a string with a single quote, you must end it with a single quote.
The same goes for double-quotes.
Python Blank Lines
If you leave a line with just whitespace, the interpreter will ignore it.
Python Keywords
These are reserved words and you cannot use them as constant or variable or any
other identifier names. All the Python keywords contain lowercase letters only.
Python Identifiers
An identifier is a name of a program element, and it is user-defined. This Python
Syntax uniquely identifies the element. There are some rules to follow while
choosing an identifier:
1. Use uppercase initials for class names, lowercase for all others.
2. Name a private identifier with a leading underscore ( _username)
3. Name a strongly private identifier with two leading underscores ( __password)
4. Special identifiers by Python end with two leading underscores.