Computer Science: Class XI (As Per CBSE Board)
Computer Science: Class XI (As Per CBSE Board)
Computer Science: Class XI (As Per CBSE Board)
Computer Science
Class XI ( As per
CBSE Board)
Python
Fundamentals
New
Syllabus
2019-20
as finally or
continue if return
del in while
elif is with
except
\\ Backslash (\)
Types of Operators
1. Arithmetic Operators.
2. Relational Operators.
3. Assignment Operators.
4. Logical Operators.
5. Bitwise Operators
6. Membership Operators
7. Identity Operators
= Assigns values from right side operands to left side operand a=b
//= Perform floor division on 2 numbers and assigns the result to left operand. a//=b
**= calculate power on operators and assigns the result to left operand. a**=b
a=30
b=20
if(a==30 and b==20):
print('hello')
Output :-
hello
not in return true if value does not exists in the sequence, else false. a not in list
E.g.
a = 22
list = [22,99,27,31]
In_Ans = a in list
NotIn_Ans = a not in list
print(In_Ans)
print(NotIn_Ans)
Output :-
True
False
Visit : python.mykvs.in for regular updates
Operators continue
7. Identity Operators
Identity operators in Python compare the memory locations of two objects.
Operators Description Example
is returns true if two variables point the same object, else false a is b
is not returns true if two variables point the different object, else false a is not b
e.g.
a = 34
b=34
if (a is b):
print('both a and b has same identity')
else:
print('a and b has different identity')
b=99
if (a is b):
print('both a and b has same identity')
else:
print('a and b has different identity')
Output :-
both a and b has same identity
a and b has different identity
Visit : python.mykvs.in for regular updates
Punctuators / Delimiters
Used to implement the grammatical and structure of a Syntax.Following
are the python punctuators.
fun()
print(x) #error will be shown
2. Global Variable
x=8
def fun():
print(x) # Calling variable ‘x’ inside fun()
fun()
print(x) # Calling variable ‘x’ outside fun()
print('hello India')
Output :-
hello India
print(‘Computer',‘Science')
print(‘Computer',‘Science',sep=' & ')
print(‘Computer',‘Science',sep=' & ',end='.')
Output :-
Computer Science
Computer & Science
Computer & Science.