Python Syntax

WHAT IS THE PYTHON SYNTAX?


Python syntax defines a set of rules that are used to create Python statements while writing a Python Program.

Case sensitivity in Python- 

Case sensitivity in Python is applicable as python is a case sensitive programming language.

Indentation in Python-

Indentation in Python is used to indicate a block of code, all statements within the block must be indented the same amount.

Identifiers in Python-

Identifier in Python is a name used to identify a variable, function, class, module or other object. An identifier starts with a letter A to Z or a to z or an underscore (_) followed by zero or more letters, underscores, and digits (0 to 9). Here are naming conventions for Python identifiers โˆ’

โ€ขPython Class names start with an uppercase letter. All other identifiers start with a lowercase letter.

โ€ขStarting an identifier with a single leading underscore indicates that the identifier is a private identifier.

โ€ขStarting an identifier with two leading underscores indicates a strongly private identifier.

โ€ขIf the identifier also ends with two trailing underscores, the identifier is a language-defined special name.

Comments in Python-

Comments start with a #, and Python will render the rest of the line as a comment.

Quotations in Python-

Python accepts single (โ€˜), double (โ€œ) and triple (โ€โ€™ or โ€œโ€โ€) quotes to denote string literals, as long as the same type of quote starts and ends the string.

Keywords in Python-

Keywords in Python are reserved for use in python language construct and should not be used as variable, constant or any other identifier name. List of these words are available by executing following command โ€“

>>> import keyword

>>> print(keyword.kwlist)

Multi-Line Statements in Python-

Multi-line statements in Python is allowed by, using at the end of the line, or writing statements in [],{}or () brackets. A Statement in Python ends with a new line or semicolon.


Posted

in

Tags:

Comments

Leave a Reply