what are the syntaxes in python ? explain one by one.
Answers
Answer:
i think it will help you
Answer:
What is Python Syntax?
The term syntax is referred to a set of rules and principles that describes the structure of a language. The Python syntax defines all the set of rules that are used to create sentences in Python programming.
Types of Syntax Structures in Python
1. Python Line Structure
A Python program comprises logical lines. A NEWLINE token follows each of those. The interpreter ignores blank lines.
2. Python Multiline Statements
This one is an important Python syntax. We saw that Python does not mandate semicolons. A new line means a new statement. But sometimes, you may want to split a statement over two or more lines. It may be to aid readability.
3.Python Comments
Python Syntax ‘Comments’ let you store tags at the right places in the code. You can use them to explain complex sections of code. The interpreter ignores comments. Declare a comment using an octothorpe (#).
4.Python Docstrings
A docstring is a documentation string. As a comment, this Python Syntax is used to explain code. But unlike comments, they are more specific. Also, they are retained at runtime. This way, the programmer can inspect them at runtime. Delimit a docstring using three double-quotes.
5.Python Indentation
Since Python doesn’t use curly braces to delimit blocks of code, this Python Syntax is mandatory. You can indent code under a function, loop, or class.
6.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. But you’d only want to do so if it supplements readability.
7.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.
8.Python Blank Lines
If you leave a line with just whitespace, the interpreter will ignore it.
9.Python Identifiers
An identifier is a name of a program element, and it is user-defined. This Python Syntax uniquely identifies the element.
10.Python Variables
In Python, you don’t define the type of the variable. It is assumed on the basis of the value it holds.
11.Python String Formatters
Now let us see the different types of String formatters in Python:
11.1%operator
11.2Format method
11.3f-strings