Python: Python is an interpreted, high level, general purpose programming language. Differences between compiler and interpreter 1) Compiler converts whole program at a time where as Interpreter conver line by line 2) Compiler generates a file where as Interpreter does not generates a file 3) Compiler is fast where as Interpreter is slow Both Compiler and Interpreter are translation softwares. Whenever we run python program, internally source code converted into byte code by python compiler, byte code converted into bit code by python virtual machine and bit code executed under operating system to get the output. Python supports scripting, structured programming, modular programming and Object Oriented Programming. Applications of python: 1) Artificial Intelligence & Machine Learning Applications 2) Data Science & Data Visualization Applications 3) Web Scrapping Applications 4) Scientific & Numeric Applications 5) IOT(Internet Of Things) Applications 6) Image Processing & Graphic Design Applications 7) Web Applications 8) Enterprise Applications ....... etc., Downloading a python software: 1) Open the browser and type the following url in address bar https://www.python.org 2) Click on "Downloads" menu and Click on "Python 3.8.2" button
Installing Python Software:
1) Double Click on "Python Software Installer" File" 2) Select "Add Python to PATH" Check box 3) Click on "Install Now" 4) Click on "Close" Button Identifiers: An identifier is user defined word and it is used to identify variables, methods, classes, packages, .. etc., It can be a variable name, method name, class name, package name, ... etc., Rules to declare an identifier: 1) It can be formed by using alphabets(A to Z & a to z), digits(0 to 9), underscore symbol(_). 2) It must begins with alphabet or underscore symbol. 3) The length of the identifier is not limited. 4) It should not contain special symbols other than underscore symbol. 5) It should not contain white space characters(Space bar, tab & enter keys). Keywords: A set of words reserved by language itself and those words are called keywords. There are 35 keywords at present in Python. To get the keywords list type the following at python shell: >>>help() help>keywords Literals: A literal is a source code representation of a fixed value. In python literals are divided into 4 categories: 1) Numeric Literals: i) Integer Literals: 5, 23, 832, 0, -2, -345, .. etc., ii) Floating Point Literals: 3.2, 0.008, -2.343, .. etc., iii) Complex Literals: 3+2j, 4+5j, 5.2+2j, .. etc., 2) String Literals: i) Single Line String Literals: 'hi', "hello", .. etc., ii) Multi Line String Literals: ''' Welcome to Python''' """ Welcome to Python """ ... etc., 3) Boolean Literals: True & False 4) Special Literals: None Data Types: A data type that determines what value variable can hold and what are the operations can be performed on variables. In Python, data types are divided into 3 categories: 1) Fudamental Types: 1) int 2) float 3) complex 4) str 5) bool 2) Collection Types: 1) list 2) tuple 3) set 4) frozenset 5) dict 3) Special Types: 1) bytes 2) bytearray 3) range 4) NoneType Variables: A variable is a container that contains data. Examples: 1) a=10 2) a,b,c=10,20,30 3) a=10;b=20;c=30; Assignment1: If we run the following code snippets, what will be happen? |
An operator is a special symbol that operates on data.
In python, operators are divided into 8 categories:
1) Arithmetic Operators
2) Relational Operators
3) Logical Operators
4) Bitwise Operators
5) Assignment Operators
6) Membership Operators
7) Identity Operators
8) Unary Operators
1) Arithmetic Operators:
Operator Meaning
+ Addition
- Subtraction
* Multiplication
/ Division
// Floor Division
% Modulo Division
** Exponentiation
Divison Operator returns quotient in floating point format where as Floor Division Operator returns quotient in integer format.
Modulo Division Operator returns remainder
Operator Precedence1 | () | Left to Right(Innermost to Outermost) |
2 | ** | Left to Right |
3 | *, /, //, % | Left to Right |
4 | +, - | Left to Right |
Assignment2:
If we run the following code snippets, what will be happen?
2) Relational Operators:
Operator Meaning
< Less than
> Greater than
<= Less than or equals to
>= Greater than or equals to
== Equals to
!= Not equals to
3) Logical Operators:
Operator Meaning
and Logical AND
or Logical OR
not Logical NOT
4) Bitwise Operators: All bitwise operators operate on binary data.
Operator Meaning
& Bitwise AND
| Bitwise OR
^ Bitwise XOR
<< Left Shift
>> Right Shift
~ Complement(Tilde)
Assignment3:
If we run the following code snippets, what will be happen?