Python Fundamentals
Python Fundamentals
Informatics
Practices
Class XI Python
Fundamenta
ls
as finally or
continue if return
del in while
elif is with
except
Identifiers
A Python identifier is a name used to
identify a variable, function, class,
module or other object.
*An identifier starts with a letter A to Z or a to
z or an underscore (_) followed by zero or
more letters, underscores and digits (0 to 9).
* Python does not allow special characters
* Python is a case sensitive programming
language.
* Identifier must not be a keyword of Python.
Thus, Rollnumber and rollnumber are two
different identifiers in Python.
Some valid identifiers : Mybook, file123, z2td, date_2,
Identifiers-continue
Some additional naming conventions
1. Class names start with an uppercase letter. All other
identifiers start with a lowercase letter.
\\ Backslash (\)
Types of Operators
1. Arithmetic Operators.
2. Relational Operators.
3. Assignment Operators.
4. Logical Operators.
5. Bitwise Operators
Operators continue
1. Arithmetic Operators
Arithmetic Operators are used to perform arithmetic operations like
addition, multiplication, division etc.
Operators Description Example
= Assigns values from right side operands to left side operand a=b
//= Perform floor division on 2 numbers and assigns the result to left a = a//b
operand.
**= calculate power on operators and assigns the result to left a = a**b
operand.
Operators continue
4. Logical Operators
Logical Operators are used to perform logical operations on the
given two variables or values.
a=3
0
b=2
0
if(a==30 and
b==20):
print('hello')
Output
Operators continue
6. Membership Operators
The membership operators in Python are used to validate whether a
value is found within a sequence such as such as strings, lists, or
tuples.
Operators Description Example
not in return true if value does not exists in the sequence, a not in list
else false.
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
Operators continue
7. Identity Operators
Identity operators in Python compare the memory locations of two
objects.
Output :-
Punctuators
Used to implement the grammatical and structure of a
Syntax.Following are the python punctuators.
Barebone of a python program
#function definition comment
def keyArgFunc(empname, emprole):
print ("Emp Name: ", Function
empname) print ("Emp Role: indentati
", emprole) return; on
A = 20 expression
print("Calling in proper sequence")
keyArgFunc(empname = "Nick",emprole =
"Manager" ) print("Calling in opposite statemen
sequence") keyArgFunc(emprole = ts
"Manager",empname = "Nick")
fun()
print(x)
#error will be
shown
2. Global
Variable
x=8
def fun():
print(
x) #
Callin
g
variab
Dynamic typing
print('he
llo
India')
Output :-
h
e
l
l
o
Input and Output
var1=‘Computer Science'
var2=‘Informatics Practices'
print(var1,' and ',var2,' )
Output :-
Computer
Science and
Informatics
Practices