0% found this document useful (0 votes)
5 views4 pages

Notes of Computer

The document provides an overview of Python programming, detailing its character set, tokens, keywords, identifiers, and literals. It explains that Python supports Unicode and defines various types of tokens, including keywords, identifiers, and literals, with specific rules for each. Additionally, it discusses string literals, including single-line and multi-line strings, and how to represent non-graphic characters using escape sequences.

Uploaded by

riddhimag89
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views4 pages

Notes of Computer

The document provides an overview of Python programming, detailing its character set, tokens, keywords, identifiers, and literals. It explains that Python supports Unicode and defines various types of tokens, including keywords, identifiers, and literals, with specific rules for each. Additionally, it discusses string literals, including single-line and multi-line strings, and how to represent non-graphic characters using escape sequences.

Uploaded by

riddhimag89
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

● Introduction

Program - It is a set of instructions that govern the processing .


Program is the base for processing.
● Python character set
Character set is a set of valid characters that a language can recognize and character
represents any letter, digits or any other symbols. Python supports the Unicode encoding
standard. That means Python has the following character set. :

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.

Python has following tokens,


First keywords, second identifier (names), third literals, 4th operators and 5th punctuators.

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.

String types in Python.


● Single line strings (basic strings).The strings that you create by enclosing text in
single quotes or double quotes are normally single line strings. They must
terminate in one line.So if at the end of a line, there is no closing quotation mark.
For an open quotation mark, Python shows an error.An escape sequence
represents a single character and hence consumes 1 byte ASCII representation.
● Multi line string Times we need to store some text spread across multiple lines as
one single string. For that Python offers multi line strings.Multiline strings can be
created in two ways.

● 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.

You might also like