Lab 1 - SR
Lab 1 - SR
Python Revision
Python is high level programming language.
Features of Python
• Simple and easy to learn
• Open source
• Support OOP
• Interpreted
Identifier
A Name in Python Program is called Identifier.
It can be Class Name OR Function Name OR Module Name OR Variable Name.
a=10
• ca$h =20 X
2. Identifier should not start with digit
• 123total X
3. Identifiers are case sensitive.
4. If identifier starts with (_) then it indicates it is private.
5. We cannot use reserved words as identifiers.
Data Types
1. Int
2. Float
3. Bool
4. Str
5. List
6. Tuple
7. Set
8. Dict
9. None
String Slicing
1. Slice means a piece
2. [] operator is called slice operator, which can be used to retrieve parts of String.
3. In Python Strings follows zero based index.
4. The index can be either +ve or -ve.
• +ve index means forward direction from Left to Right
• -ve index means backward direction from Right to Left
Escape Characters
The following are various important escape characters in Python
1. \n: New Line
2. \t: Horizontal Tab
3. \b: Back Space
4. \': Single Quote
5. \": Double Quote
6. \\: Back Slash Symbol
Arithmetic Operators
1. + → Addition
2. - → Subtraction
3. * → Multiplication
4. / → Division Operator
5. % → Modulo Operator
6. // → Floor Division Operator
7. ** → Exponent Operator OR Power Operator
Relational Operators
>, <, >=, <=
Equality Operators
==, !=
Logical Operators
And, or, not
NumPy
NumPy is a Python library used for working with arrays.
It also has functions for working in domain of linear algebra, fourier transform, and matrices.
0-D Array
0-D arrays, or Scalars, are the elements in an array. Each value in an array is a 0-D array.
1-D Array
An array that has 0-D arrays as its elements is called uni-dimensional or 1-D array.
These are the most common and basic arrays.
2-D Array
An array that has 1-D arrays as its elements is called a 2-D array.
These are often used to represent matrix
Number of Dimensions