Tuples
A Tuple is a set of comma-separated values of any data type inside the parentheses ( )
Example => (1, 2 , 3 , 4, 5)
(1.5, 2.5, 4.5, 9.8)
(‘x’, ‘y’, ‘z’)
(‘anjeev’, 25, 4589.36, True )
Tuple can also be accessed through the index position i.e. forward and backward.
Dictionary
A dictionary is a comma-separated key-value pairs within { } and accessed using keys.
No two keys can be the same .
Example : mon ={‘j’: ‘Jan’, ‘f’: ‘Feb’, ‘m’: ‘Mar’}
mon[‘j’] => Jan
values = { ‘a’: 1, ‘e’: 2, ‘i’: 3, ‘o’: 4, ‘u’ : 5 }
Mutable and Immutable Data Types
Immutable Types
Immutable types are those that can never change their value in place.
The following are immutable: integers, floating point numbers, Boolean, strings, tuples
In immutable types, the variable names are stored as a reference to a value object, each time when we change the value, the variable’s reference memory address changes.
Note : use id( ) method to get the memory address/reference.
Mutable Types
The Mutable types are those whose values can be changed in place. The following are mutable : lists, dictionaries, and sets
Operators and Its Types
Arithmetic Operator
Operator | Description |
+ (unary) | Explicitly express a +ve number. Example : +3, +98.36 |
– (unary) | Explicitly express a –ve number. Example : -3, -369.36 |
+ (binary) | Add two numbers, Example: 9 + 6 is 15 |
– (binary) | Subtract one value from another number. Example: 9 – 3 is 6 |
* | Product of two numbers. Example 9 * 6 is 54 |
/ | Gives a quotient, when one value is divided by the other. Example 9/ 6 is 1.5 |
// (floor division) | Gives the integer part of the quotient, when one value is divided by the other. Example 9//6 is 1. |
% (Remainder) | Gives remainder when one value is divided by the other. Example 9 % 6 is 3 |
** (Exponent) | To raise a number to the power of another number. For example, 3**2 is 9 |
Assignment Operator
Operator | Description |
= | Called Assignment operator. Assign a value to the variable. Example, x = 20. |
+= | Add and Assign, Add the R-Value to the L-Value and assign result to L-value. Example x=20, x += 30 it means x = x + 30 so the new value of x is 50. |
-= | Subtract and Assign, Subtract the R-Value from L-Value and assign result to L-value. Example x=50, x -= 30 it means x = x – 30 so the new value of x is 20. |
*= | Multiply and Assign, Multiply the R-Value with L-Value and assign product to L-value. Example x=50, x *= 3 it means x = x * 3 so the new value of x is 20. |
/= | Divide and Assign Quotient, Divide the L-value with R-Value and assign quotient to L-value. Example, x = 50, x /= 6 its means x = x / 6, and the new value of x is 8.33333…… |
//= | Floor and assign, Divide the L-value with R-Value and assign integer quotient (floor division) to L-value. Example, x = 50, x //= 6 its means x = x // 6, and the new value of x is 8. |
%= | Divide and Assign Remainder, Divide the L-value with R-Value and assign remainder to L-value. Example, x = 50, x %= 6 its means x = x % 6, and the new value of x is 2. |
**= | Exponent and Assign, Calculate (L-Value)R-Value and assign the result to L-value. Example, x = 3, x**=2 its means x = x2 and the result of x is 9 |
Relational Operator
Operator | Description |
== (Equality) | Compares two values for equality, Returns True if they are equal, otherwise returns False. |
!= (Not equal) | Compares two values for inequality, Returns True if they are not equal, otherwise returns False. |
< (Less than) | Compares two values, Returns True if first value is less than the second, otherwise returns False. |
> (greater than) | Compares two values, Returns True if first value is greater than the second, otherwise returns False. |
<= (Less than or equal to) | Compares two values, Returns True if first value is less than or equal to the second, otherwise returns False. |
>= (greater than or equal to) | Compares two values, Returns True if first value is greater than or equal to the second, otherwise returns False. |
Logical Operator
Operator | Description |
not | Negate a condition and Returns True if the condition is false otherwise returns False. |
and | Combines two conditions and returns True if both the conditions are true, otherwise returns False. |
or | Combines two conditions and returns True if at least one of the condition is true, otherwise returns False. |
Bitwise Operator
Operator | Description |
& (bitwise and) | The AND (&) operator compares two bits and generates a result of 1 if both bits are 1 otherwise, it returns 0 |
| (bitwise or) | The OR (|) operator compares tow bits and generate a result 1 if the bits are complementary, otherwise it returns 0. |
^ (bitwise xor) | The EXCLUSIVE-OR (XOR) operator compares two bits and return 1 if either of the bits are 1 and it gives 0 if both bits are 0 or 1 |
~ (bitwise complement) | The COMPLEMENT operator is used to invert all of the bits of the operand. |
Note: bin( ) returns binary representation number.
Membership Operator
Operator | Description |
in | Returns True if the given value is available in the sequence (like sting, tuples, lists, dictionary, etc.) otherwise returns False. |
not in | Returns True if the given value is not available in the sequence (like sting, tuples, lists, dictionary, etc.) otherwise returns False. |
Identity Operator
Operator | Description |
is | Returns True, if both operands have the same identity i.e. memory reference, otherwise return False |
Is not | Returns True, if both operands have not the same identity i.e. memory reference, otherwise return False |
Operator Precedence :
Execution of the operator depends on the precedence of the operator.
Order | Operator | Description |
Highest | () | Parentheses |
↑ | ** | Exponentiation |
| | ~ | Bitwise nor |
| | +, – | Unary plus and Minus |
| | *, /, //, % | Multiplication, Division, floor division, remainder |
| | +, – | Addition, Subtraction |
| | & | Bitwise and |
| | ^ | Bitwise XOR |
| | | | Bitwise OR |
| | <, <=, >, >=, <>, !=, ==, is, is not | Relational Operators, Identity Operators |
| | not | Boolean NOT |
↓ | and | Boolean AND |
Lowest | or | Boolean OR |
Expression
In Python, An expression is a valid combination of operators, literals, and variables.
There are three types of Expression in Python, These are-
•Arithmetic Expressions:- combination of integers, floating-point numbers, complex numbers, and arithmetic operators. Example; 2+9, 9.2/3
•Relational Expression :- combination of literals and/or variables of any valid type and relational operators . Example; x > y, 5 < 8, z == y
•Logical Expression:- combination of literals, variables and logical operators. Example; t and q, p or g
•String Expression :- combination of string literals and string operators ( + -> concatenate, and * -> replicate). Example;
“Hello” + “Anjeev” = “Hello Anjeev”
“Like” * 3 = “LikeLikeLike”
Types Casting / Explicit Type Conversion
The conversion of one type to a specific type explicitly, is called Type Casting / Explicit Type Conversion.
Syntax: <type>( )
Example x = int ( “123”)
y = float(“5369.36”)
z = str(598698.36)
Comments in Python
Comments are a non-executable statement in Python, used for the documentation of the program i.e. specify the purpose of the program, the purpose of expression, variables, statements, blocks, etc.
There are two types of Comments in Python –
•Full Line or Inline Comment
# symbol is used to write a single or inline comment in Python ->full line comment
r = 20 # rate of interest -> inline comment
•Multiline Comments or Block Comments
‘’’ ‘’’ or “”” “”” – triple quotes (single or double) are used for multiline comments in python..
Click here for –
Python Revision Tour – I (B) : Decision-Making Statements
Python Revision Tour – I (C): Looping & Jump Statements
Class 12 Computer Science
- CBSE Board Class 12 Answer Key Computer Science 083
- Class 12 Computer Science Ch 11 Data Communication NCERT Book Exercise Solution
- Class 12 Computer Science Answer Key (083) Term 1 Question Paper download pdf
- Class 11 Computer Science Chapter 5 Getting Started with Python NCERT Solution
- Input Output in Python
- Python Data Types
- Class 12 Computer Science File Handling in Python NCERT Exercise solution
- Class 12 Computer Science – Exception Handling in Python NCERT Exercise Solutions
- Python 3 Setup and Installation Guide
- Encoding Schemes and Number Systems NCERT Exercise solutions
- Python Important Programs and Practical’s
- CBSE Annual Exam Question Paper for Class 11 Computer Science Sample Papers
- Ch 2 Emerging Trends NCERT Exercise Solution – Class 11 Computer Science
- 110+ Important Networking Full Form List – Download PDF
- Class 12 Computer Science NCERT Exercise Solution
- Class 11 Computer Science NCERT Exercise Solution
- Computer System: Overview – Notes
- Number Systems & Encoding Scheme – Notes
- Boolean Logics – Notes
- Emerging Trends – Notes
- About Us (3)
- Artificial Intelligence (20)
- CBSE Class 10 Artificial Intelligence Question Bank (5)
- Class 10 Artificial Intelligence (5)
- Class 10 Unit 1 Introduction to Artificial Intelligence (1)
- Class 10 Unit 7 Evaluation (1)
- Class 12 Artificial Intelligence (3)
- Class 9 Artificial Intelligence (3)
- Class 9 Unit 1 Introduction to Artificial Intelligence (1)
- Natural Language Processing (3)
- CBSE (12)
- Class 12 Informatics Practices (2)
- Computer Application [165] (38)
- Computer Network (7)
- Computer Science (89)
- Daily Current Affairs (27)
- Daily News Headlines (19)
- Employability Skills (66)
- Class 10 Employability Skills (32)
- Class 10 Employability Skills MCQ (5)
- Class 10 Employability Skills NCERT Solution (7)
- Class 10 Employability Skills Notes Study Material (4)
- Class 10 Employability Skills Question Answer (6)
- Class 10 Employability Skills Question Bank (3)
- Communication Skills II (2)
- Entrepreneurial Skills II (2)
- Green Skills – II (2)
- ICT Skills – II (1)
- Self Management Skills II (2)
- Class 11 Employability Skills (2)
- Class 12 Employability Skills (12)
- Class 9 Employability Skills (19)
- Class 10 Employability Skills (32)
- General Knowledge (4)
- General Knowledge in Hindi (5)
- Informatics Practices (61)
- Class 11 Informatics Practices – Notes (7)
- Class 11 Informatics Practices NCERT Solution (9)
- Class 12 Informatics Practices – Notes (14)
- Class 12 Informatics Practices CBSE Sample Paper (1)
- Class 12 Informatics Practices NCERT Solution (6)
- Class 12 Informatics Practices Term 1 MCQS (4)
- Data Visualization Matplotlib MCQs (4)
- Python Pandas – I (1)
- Python Pandas MCQs (3)
- Syllabus of Informatics Practices (6)
- Information Technology (114)
- Class 10 Info Tech 402 MCQ's (12)
- Class 10 Info. Tech. [402] (77)
- Class 10 Digital Documentation (6)
- Class 10 Digital Documentation Que Ans (6)
- Class 10 Electronic Spreadsheet Advanced (4)
- Class 10 Electronic Spreadsheets Que Ans (3)
- Class 10 Info Tech NCERT Solution (8)
- Class 10 Info Tech Term 1 Sample Paper (1)
- Class 10 Information Technology 402 NCERT Solution (13)
- Class 10 Information Technology Code 402 Notes (4)
- Class 10 RDBMS (10)
- Class 10 Web Application and Security (13)
- Info Tech Term 2 Sample Paper (2)
- Class 12 Information Technology 802 (19)
- Class 12 Information Technology 802 NCERT Book Solution (4)
- Class 9 Info Tech 402 (9)
- Info Tech CBSE Sample Paper (3)
- Syllabus of Info. Tech. (2)
- ncert training (3)
- Order Form (1)
- Policy (1)
- Practical File (2)
- Project (2)
- Python Pandas Project (1)
- Python Programs (3)
- Python Project (2)
- Quiz (19)
- Sample Paper (19)
- Teacher's Eligibility Test (4)
- CTET (4)
- Uncategorized (16)