Page 86 - KEC Khaitan C7 Flipbook
P. 86
IDENTIFIERS
An identifier is a sequence of characters taken from the Python character set. It refers to variables,
functions and arrays. The rules for identifiers are:
Only letters, digits and an underscore are permitted.
Must start with a letter between A to Z or between a to z or an underscore (_).
Uppercase and lowercase are distinct because Python is a case sensitive language.
Special characters are not allowed.
Some examples of valid identifiers are Myvar, myvar_1, Sum_of_the_numbers, PASS and _Sum.
Some examples of invalid identifiers are False, Var^2, Var 1 and 1var.
KEYWORDS
Keywords are the reserved words. They are predefined words. Keywords cannot be used as an
identifier.
Some commonly used keywords in Python are given below:
False assert del for in or while
None break elif from is pass with
True class else global lambda raise yield
and continue except if nonlocal return async
as def finally import not try await
CONSTANTS OR LITERALS
Constants are fixed values that do not change during the execution of a program. Literals are the
type of constant. Literals refer to any number, text and other information that represents a value.
Python supports the following literals:
Literals Example
String literals “hello”, ‘12345’
Integer literals 0, 1, 2, -1, -2
Long literals 89675
Floating-point literals 3.14
Complex literals 12j
Boolean literals True or False
Special literals None
Unicode literals u“hello”
List literals [5,6,7]
84 Premium Edition-VII

