Python Overview Class 11 - Day 2
Python Character Set
- Character set is the set of valid characters that a language can recognize.
- A character represents any letter, digit or any other symbol.
- Python has the following character sets: ·
- Letters – A to Z, a to z · Digits – 0 to 9
- Special Symbols - + - * / etc.
- Whitespaces – Blank Space, tab, carriage return, newline, formfeed
- Other characters – Python can process all ASCII and Unicode characters as part of data or literals.
Tokens
- In a passage of text, individual words and punctuation marks are called tokens or lexical units or lexical elements.
- The smallest individual unit in a program is called token or lexical unit
- Python has the following tokens:
- Keyword
- Identifiers
- Literals
- Operators
- Punctuators
1. Keywords ( Reserved words)
A keyword is a word having a special meaning reserved by the programming language
- Identifiers are are names used to identify a variable, functions, objects, classes, lists, dictionaries or other entities in a program
- These are the rules for forming an Identifier in Python
- The name should begin with uppercase or lowercase alphabet or an underscore sign(_). This may be followed by any combination of characters a-z, A-Z, 0-9 or underscore(_). Note: Name or Identifier cannot start with a digit.
- It can be of any length but keep it short and meaningful
- Python is case sensitive as it treats uppercase and lowercase characters differently
- Must not be a Keyword or reserved word ( verify Keyword table given above)
- Cannot have special symbols like !, @, #, $, % etc Note: Only _ is allowed
Valid Identifiers:
Comments
Post a Comment