CLASS -11 COMPUTER SCIENCE
CHAPTER-3 DATA HANDLING
🔔To download textbook pdf click on the ''DOWNLOAD'' button below -
DOWNLOAD TEXTBOOK
NOTES FOR COMPLETE UNDERSTANDING -
- Data can be any type from the followed list - character, integer, real, string.
- Anything enclosed in single , double or triple quotes is considered as string in Python.
- Any whole value is an integer value.
- Any value having fraction part is a real value.
- True or False value specifies boolean value.
- Python supports below core data types - I. Numbers (int like 4,9) (float like 3.6 , 302.74) (complex like 3+5i) II. String (like “pankaja”,‘pankaj’,‘a’, “b” ) III. List like [3,4,5,”pankaj”] its elements are Mutable. IV. Tuple like(3,4,5,”pankaj”) its elements are immutable. V. Dictionary like {‘a’:1, ‘e’:2, ‘I’:3, ‘o’:4, ‘u’:5} where a,e,i,o,u are keys and 1,2,3,4,5 are their values.
- Data Objects can be categorized in two types-
- Mutable (Changeable) • Immutable (Non-Changeable)
- An important fact to know is- – In Python, values are actually objects. – The variable names are in real their reference names
- Following comes under mutable and immutable types- • Mutable (updatable) – lists, dictionaries and sets. • Immutable (Non-updatable) – integers, floats, Booleans, strings and tuples.
- Those symbols that shows special action when triggered on to operands are called operators. For ex- + , - , > , < etc.
- Python supports following operator I. Arithmetic Operator II. Relation Operator III. Identity Operators IV. Logical Operators V. Bitwise Operators VI. Membership Operators
- Arithmetic Operators :
- Python has following binary arithmetic operator -
- For addition + for ex- 2+3+5 will result in to 10
- For subtraction – for ex- 6-3 will result in to 3
- For multiplication * for ex- 2*8 will result in to 16
- For division / its result comes in fraction. for ex- 15/2 will result in to 7.5
- For quotient // its result comes as a whole number for ex- 13/2 will result into 6.
- For remnant % its result comes as a whole remnant number.For ex-13/2will result into 1.
- For exponent ** it will come as per exponent value. For ex- 2**3 will result into 8.
- Assignment Operators and shorthand
- Following are assignment operator and shorthand -
- a=11 , 11 will be assigned to a.
- a+=15 is equal to a=a+15.
- a-=50 is equal to a=a-50.
- a*=4 is equal to a=a*4.
- a/=56 is equal to a=a/56.
- a//=3 is equal to a=a//3.
- a%=6 is equal to a=a%6.
- a**=2 is equal to a=a**2.
- Relational Operators :
- In python we use Relational operators to check for equality.
- These results into true or false.
- Relational Operator are of following types-
- < Less Than like a Greater Than like a>b
- <= Less Than and Equal to like a<=b
- >= Greater Than and Equal to like a>=b
- == Equal to like a==b • != not Equal to like a!=b
- Identity Operators :
- Identity operator is also used to check for equality.
- These expressions also results into only two outputs i.e. True or False.
- Identity Operators are of following types-
- “is” operator if a=75 and b=75 then a is b will come to True
- “is not” operator if a=85 and b=85 then a is not b will come to False
- Logical Operators :
- There are two binary logical operators in python -
- or operator » if a = True and b = False then a or b will return True.
- and operator » If a = True and b = False then a and b will return False.
- Python has one Unary logical operator –
- not operator
- if a = True then not a will return False.
- Operator Associativity
- In Python, if an expression or statement consists of multiple or more than one operator then operator associativity will be followed from left-to-right.
- In above given expression, first 7*8 will be calculated as 56, then 56 will be divided by 5 and will result into 11.2, then 11.2 again divided by 2 and will result into 5.0. *Only in case of ** , associativity will be followed from right-to-left. for eg . 3**3**2
- Above given example will be calculated as 3**(3**2).
- Expressions :
- Python has following types of expression -
- Arithmetic Expressions like a+b , 5-4 etc.
- Relational Expressions like a>b, a==b etc.
- Logical Expressions like p>b and q>c , r or p etc.
- String Expressions like “Pankaja” + “Kumari” etc.
- Type Casting :
- In Python, an expression may have mixed datatypes.
- In such cases, it changes data types of operands internally.
- Above process of internal conversion of data type is called implicit type conversion.
- One other option is explicit type conversion which is like-
(identifier) For eg.=“4” b=int(a) Another eg. If a=5 and b=10.5 then we can convert a to float. Like d=float(a) Following are the data conversion functions- (1) int ( ) (2) float( ) (3) complex( ) (4) str( ) (5) bool( )
- math Module of Python :
- Python provides math module to work on all mathematical works.
- You need to write following statement in our program "import math" to import the module for further use in the program .
- Taking Input in Python :
- input () function is used to take input which takes input in the form of string.
🔔MORE MATERIALS TO BE UPLOADED STAY TUNED🔔