PYTHON NOTES DOWNLOAD CLICK BELLOW
Introduction:
Characteristics of Python:
Python Interpreter:
Interactive Mode:
Note: >>> is a command the python interpreter uses to indicate that it is ready. The interactive mode is better when a programmer deals with small pieces of code. To run a python file on command line: exec(open(“C:\Python33\python programs\program1.py”).read( )) ii. Script Mode: In this mode source code is stored in a file with the .py extension and use the interpreter to execute the contents of the file. To execute the script by the interpreter, you have to tell the interpreter the name of the file. Example: if you have a file name Demo.py , to run the script you have to follow the following steps: Step-1: Open the text editor i.e. Notepad Step-2: Write the python code and save the file with .py file extension. (Default directory is C:\Python33/Demo.py) Step-3: Open IDLE ( Python GUI) python shell Step-4: Click on file menu and select the open option Step-5: Select the existing python file Step-6: Now a window of python file will be opened Step-7: Click on Run menu and the option Run Module
Python Character Set
: It is a set of valid characters that a language recognize. Letters: A-Z, a-z Digits : 0-9 Special Symbols Whitespace
TOKENS Token:
Smallest individual unit in a program is known as token. There are five types of token in python: 1. Keyword 2. Identifier 3. Literal 4. Operators 5. Punctuators 1. Keyword: Reserved words in the library of a language. There are 33 keywords in python.
Identifier:
The name given by the user to the entities like variable name, class-name, function-name etc.
Rules for identifiers:
It can be a combination of letters in lowercase (a to z) or uppercase (A to Z) or digits (0 to 9) or an underscore. It cannot start with a digit. Keywords cannot be used as an identifier. We cannot use special symbols like !, @, #, $, %, + etc. in identifier. _ (underscore) can be used in identifier. Commas or blank spaces are not allowed within an identifier. 3. Literal: Literals are the constant value. Literals can be defined as a data that is given in a variable or constant.
MUTABLE & IMMUTABLE Data Type:
Mutable Data Type: These are changeable. In the same memory address, new value can be stored. Example: List, Set, Dictionary Immutable Data Type: These are unchangeable. In the same memory address new value cannot be stored. Example: integer, float, Boolean, string and tuple.
Basic Operators in Python:
i. Arithmetic Operators ii. Relational Operator iii. Logical Operators iv. Bitwise operators v. Assignment Operators vi. Other Special Operators o Identity Operators o Membership operators i. Arithmetic Operators: To perform mathematical operations.
Comments
Post a Comment
WHICH PROGRAMMING LANGUAGE IF YOU WANT COMMENTS HERE I WILL BE SEND