Notes of Computer
Notes of Computer
Every component of a Python program is created using the character set, be its statement or
expression or other components program.
● Tokens
In a passage of text, individual words in punctuation marks are called tokens or lexical units or
lexical elements. The smallest individual unit in a program is known as a token or lexical unit.
1
➢ Keywords
They are the words that convey a special meaning to the language compiler / interpreter. These
are reserved for special purposes and must not be used as normal identifier names.
➢ Identifiers(name)
Identifiers are the fundamental building blocks of a program and are used as the general
terminology for the names given to the different parts of the program. identifier forming rules of
Python are being specified below ;
1.An identifier is an arbitrarily long sequence of letters and digits.
2.The first character must be a letter under the under score count as a letter.
3.Upper and lower case letters are different. All characters are significant.
4.The digit 0 through 9 can be part of the identifier except for the first character.
5.identifiers are unlimited in length. Case is significant i.e Python is case sensitive as it treats
upper and lower case characters differently.
6.Identify must not be a keyword of Python.
7.An identifier cannot contain any special character except for under score(_).
➢ Literal/value.
Literals, often referred to as constant values, are data items that have a fixed value.
Python allows several kinds of literal
1.string literal
2.numeric literals
3.boolean literals
4. special literals
5. literal collection.
1.string literal
The text enclosed in quotes forms a string literals in Python.One can form string literals by
enclosing text in both forms of quotes, single quotes or double quotes.Python allows you to
2
have certain non graphic characters in string values. Non-graphic characters are those
characters that cannot be typed directly from the keyboard. Example backspace, tabs, carriage
return, etc. No character is typed When these keys are pressed, only some action takes place;
these non-graphic characters can be represented by using escape sequences. An escape
sequence is Represented by a backslash followed by one or more characters.
● a)
● b)By typing the text in triple quotation marks, no backslash needed at the end of
the line, Python allows you to type multi line text string by enclosing them in triple
quotation mark.Both triple apostrophe or triple quotation mark will work.
3
Size of string
For multiline strings, headed triple quotes, while calculating the size, the EOL end of line
character at the end of the line is also counted in the size.
Triple quoted multiline strings count end of nine characters in the size of the string, but do not
count back slashes at the end of the intermediate lines.
To check the size of a string, you may also type Len(<stringname>) .
2.numeric literals
The numeric literals in Python can belong to any of the following three different American types.