PYTHON REVISION TOUR I
CHAPTER CHECKLIST
- Python Character Set
- Python Tokens
- Basic structure of Python Program
- Variables and Assignments
- Input and Output in Python
- Data Types
- Mutable and Immutable
Types - Expressions
- Type conversion in Python
- Statements
- Programming Tools
- Control Structure
- Jump Statements
PYTHON REVISION TOUR I​
Introduction to Python.
Python is a general purpose interpreted, interactive, object oriented and high level programming language.
It was initially designed by Guido Van Rossum in 1991 and developed by Python Software Foundation.
PYTHON CHARACTER SET
Character set is a set of valid characters that represents any digit, alphabet and special symbol.
The character used in a Python source program belongs to unicode standard.
Python supports the following character sets
Alphabets – A to Z (uppercase), a to z (lowercase)
Digits – 0 to 9
Special Characters Space () + -* / ^ 82% # $ (} []!_ (underscore) ><?@ ‹ ” etc.
White Space Blank space, Horizontal tab (→), Carriage return (-), Newline, formfeed
Other Characters Python can process any of the ASCII and unicode characters as data or as literals
PYTHON TOKENSÂ
A smallest individual unit in a program is known as token or lexical unit or lexical element.
The Python has following tokens:
identifiers
keywords
literals
operators
punctuators
identifiers :-Â
Identifiers are names used to identify a variable, function, or other entities in a program.
The rules for naming an identifier in Python are as follows
The name should begin with an uppercase or a lowercase alphabet or an underscore sign ().
This may be followed by any combination of characters a-z, A-Z, 0-9 or underscore (). Thus, an identifier cannot start with a digit.
It can be of any length.
It should not be a keyword or reserved word.
We cannot use special symbols like !, @, #, $, %, etc. in identifiers.
Keywords :-Â
Keywords are predefined reserved words that have some special or predefined meanings.
These are reserved for special purpose and must not be used as identifier names.
Some commonly used keywords in Python, which are listed below
| False | assert | del | for |
|---|---|---|---|
| in | or | While | None |
Constants or Literals :-Â
- Literals refer to fixed values that the program may not alter (change) during the program execution.
Python allows several types of literals as follows
Numeric literals
String literals
Boolean literals
Special literal None
Literal collections
1. Numeric Literals :-
Represent numbers and can be of the following types:
Integer (int): Whole numbers, e.g., 10, -5.
Floating-point (float): Numbers with a decimal point, e.g., 3.14, -0.001.
Complex numbers (complex): Numbers with a real and imaginary part, e.g., 5 + 3j.
2. String Literals :-Â
Represent text enclosed in quotes:
Single-line strings: Enclosed in single (‘) or double (“) quotes, e.g., ‘Hello’, “Python”.
Multi-line strings: Enclosed in triple quotes (”’ or “‘).
3. Boolean Literals :-
- Represent truth values:
- True
- False
Â
Â