Page 73 - ModularV1.1 _c8_flipbook
P. 73
String: This data type stores a sequence of characters including alphabets, numbers and
special symbols. A string value is defined inside single or double quotation marks. For example:
s1 = 'Py' or s2 = "thon"
List: The list data type can store series of values within square brackets.
For example: L = [23, 13.12, 2802, 'Orange', "Education"]
Tuple: The tuple data type can store series of values within parentheses.
For example: T = (23, 23.07, 2112007, "Python")
Dictionary: A dictionary is a collection of key-value pairs of any type within { } brackets.
For example: dict = {1:'abc', 'x':4, 2:8}
None: This data type represents the absence of value. For example, num1 = None
OPERATORS
Operators are special symbols in Python that are used to perform arithmetic or logical computation.
They are used along with operands or values to get the desired result.
For example: 5 + 3 Operator
Operands
There are various types of operators, that are as follows:
Arithmetic operators Relational operators Logical operators
Let's discuss them in detail.
Arithmetic Operators
These operators are used to do basic mathematical calculations.
Operator Name Syntax Example (a = 11, b = 4) Output
+ Addition a + b >>> a + b 15
– Subtraction a – b >>> a – b 7
* Multiplication a * b >>> a * b 44
/ Division a / b >>> a / b 2.75
// Floor or Integer Division a // b >>> a // b 2
% Remainder a % b >>> a % b 3
** Exponentiation a ** b >>> a ** b 14641
Let’s write a simple Python Program using arithmetic operators:
Step 1 Click on Start → All programs → Python
3.7 → IDLE(Python 3.7 32-bit)
Step 2 Click on File → New File.
Type the code in the editor window as
shown.
Writing a program
Introduction to Python 71

