/**/ Sanjeev Study Hub – Class 11 & 12 Notes, Question Papers, IP & CS Study Material

Tuesday, August 4, 2020

PYTHON FUNDAMENTAL (CLASS - XI) PART -2

PYTHON FUNDAMENTAL

CHAPTER -IV (PART - 2)

CLASS – XI

Operators

Operators can be defined as symbols that are used to perform operations on operands. In other word, operators are tokens that trigger some computation when applied to variables and other objects in an expression. Variables and objects to which the computation is applied, are called operands.

Types of Operators

1. Arithmetic Operators

2. Relational Operators

3. Assignment Operators

4. Bitwise Operators

5. Logical Operators

6. Membership Operators

7. Identity Operators

1. Arithmetic Operators: It is used to perfor arithmetic operations like addition, subtraction, multiplication, division etc

Operators

Description

Example

+

Perform addition of two number

x+y

-

Perform subtraction of two number

x-y

/

Perform division of two number

x/y

*

Perform multiplication of two number

x*y

%

Modules = return remainder

x%y

//

Floor Division = remove digits after the decimal point

x//y

**

Exponent = perform raise to power

x**y


2. Relational Operators: Relational operators are used to compare the values.

Operators

Description

Example

==

Equal to, return true if x equal to y

x == y

!=

Not equal, return true if x is not equals to y

x ! = y

> 

Greater than, return true if x is greater than y

x > y

>=

Greater than or equal to, return true if x is greater than y or x is equals to y

x >= y

< 

Less than, return true if x is less than y

x < y

<=

Less than or equal to, return true if x is less than y or x is equals to y

x <= y

3. Assignment Operators: Used to assign values to the variables.

Operators

Description

Example

=

Assigns calues from right side operands to left side operand

x=y

+=

Add 2 numbers and assigns the result to left operand.

x+=y

/=

Divide 2 numbers and assigns the result to left operand.

x/=y

*=

Multiply 2 numbers and assigns the result to left operand.

x*=y

-=

Subscrats 2 numbers and assigns the result to left operand.

x-=y

%=

Modules 2 numbers and assigns the result to left operand.

x%=y

//=

Perform floor division on two numbers and assigns the result to left operand.

x//=y

**=

Calculate power on operators and assigns the result to left operand.

x**=y

4. Logical Operators: It is performed logical operations on the given two variables or values.

Operators

Description

Example

and

Return true if both conditions are true

x and y

or

Return true if either or both conditions are true

x or y

not

Reverse the condition

Not(x>y)


Example:

x = 5

y = 10

if(x==5 and y==10):

print(“Hello Python”)

Output

Hello Python

5. Membership Operators: The membership operators in Python are used to validate whether a value is found within a sequence such as strings, lists, or tuples.

Operators

Description

Example

in

Return true if value exists in sequence, else false.

a in list

not in

Return true if value does not exists in sequence, else false.

a not in list


Example:

a = 10

list = [10, 20, 30, 40, 50]

y = a in list

z = a not in list

print(y)

print(z)

Output:

True

False

6. Identity Operators: Identity operators in Python compare the memory of two objects.

Operators

Description

Example

is

Return true if 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


Example:

a = 15

b = 14

if(a is b):

print(“Both a and b has same identity”)

else:

print(“a and b has different identity”)

b = 75

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

7. Bitwise Operators:

Operators

Description

Example

&

Bitwise AND

a & b

^

Bitwise exclusive OR (XOR)

a ^ b

|

Bitwise OR

a | b


Punctuators: Punctuators are symbols that are used in programming languages to organize sentence structures, and indicate the rhythm and emphasis of expressions, statements, and program structure.

Most common punctuators are:

Barebones of a Python Program: Now we are going to talk about the basic structure of a Python program – what all it can contain. Before we proceed, have a look at following sample code.


A Python program contain the following components

a. Expression

b. Statement

c. Comments

d. Function

e. Block & Indentation

a. Expression: Which is evaluated and produce result. E.g. (20+5)/5

b. Statement: Instruction that does something. E.g.

                                             a = 25

                                             print (“Calling in proper sequence”)

c. Comments: Which is readable for programmer but ignored by python interpreter.

               1. Single line comment: Which begins with # sign.

               2. Multi line comment (docstring): either write multiple line beginning with # sign or use

      triple quoted multiple line. E.g.

               ‘’’this is my

                     First python

                    Multi line comment

               ‘’’

d. Function: A code that has some name and it can reused. E.g. keyArgFunc in above program

e. Block & indentation: Group of statements is block. Indentation at same level create a block. E.g.  all 3 statement of keyArgFunc function

VARIABLES: amed labels, whose values can be used and processed during program run, are called Variables.

Assigning Values To Variable

name = ‘Python’               # String Data Type

sum = None                       # variable without value

a = 35                                  # Integer

b = 5.5                                 # Float

sum = a + b

print(sum)

Multiple Assignment: Assign a single value to many variables like

a = b = c = 1        # single value to multiple variable

a, b = 5, 6            # multiple value to multiple variables

a, b = b, a                           =# value of a and b is swaped

Variable Scope And Lifetime in Python Program

1. Local Variable

               def fun():

                              x = 10

                              print (x)

               fun()

               print(x) #error will be shown

2. Global Variable

               x = 15   

               def fun():

                              print(x)  # Calling variable ‘x’ inside fun()

               fun()

               print(x)  # Calling variable ‘x’ outside fun()

Dynamic Typing

Data type of a variable depend/change upon the value assigned to a variable on each next statement.

X = 40                   # integer type

X = ‘Hello’           # X variable data type change to string on just next line

Now programmer should be aware that not to write like this:

Y = X/5 # error because String cannot be devided.

Input and Output

print() Function in Python is used to print output on the screen.

Syntax of Print

               print(expression/variable)

e.g. print(95)

Output: 95

 

print(‘Hello Python!’)

Output: Hello Python!

print(‘Informatics’, ‘Practices’)

print(‘Informatics’ ‘Practices’, sep = ‘&’)

print(‘Informatics’ ‘Practices’, sep = ‘&’, end=’.’)

Output:

Informatics Practices

Informatics & Practices

Informatics & Practices.



Note: This is the notes of Chapter -4 PYTHON FUNDAMENTAL (SECOND PART). It is important for every students. By the help of these notes students can prepare for their Exam.


!!! THANK YOU !!!








PYTHON FUNDAMENTAL (CLASS - XI) PART - 1

PYTHON FUNDAMENTAL

CHAPTER -IV (PART - 1)

CLASS – XI


INTRODUCTION

In this chapter, we will learn about all basic elements that a python program can contain. You’ll be learning about Python’s basics like Character set, tokens, expressions, statements, simple input and output etc.

Python Character Set: A set of valid characters recognized by python. Python uses the traditional ASCII character set. The latest version recognizes the Unicode character set. The ASCII character set is a subset of the Unicode character set.

Letters: A-Z, a-z

Digits: 0 to 9

Special Symbols: Special symbol available over keyboard like +, -, ( ), *, & ^ %, !, @, # , etc.

White Space: Blank space, tab, carriage return, new line, form feed.

Other Characters: Python can process all ASCII and Unicode characters as part of data or literals.

Example:

a1 = ‘Informatics Practices’

b1 = ‘Computer Science

print (‘a1’, and, ‘b1’)

The output will be

Informatics Practices and Computer Science

raw_input(): Function in Python allow a user to give input to a program from a keyboard but in the form of string

Exampe:

name =int(input(“Enter your Name”))

age = int(input(“Enter your Age”))

per = float(input(“Enter your Percentage”))

Token

The smallest individual unit in a program is known as a Token or a lexical unit.

1. Keywords

2. Identifiers

3. Literals

4. Operators

5. Punctuators

Keywords: Reverse words of the compiler/interpreter which can’t be used as identifier.

and

Del

is

yield

not

as

For

pass

expect

try

assert

In

with

if

False

break

Or

else

nonlocal

True

class

While

global

return

None

continue

Elif

lambda

finally

 

def

From

raise

import

 



Identifiers: A Python identifier is a name used to identify a variable, function, class module, list, dictionaries or other objects.

Some important points for identifier:

An identifier starts with a letter A to Z or a to z or and underscore(_) followed by zero or more letters, underscore and digits (0 to 9).

Python does not allow special characters.

Identifier must not be a keywords of Python.

Python is a case sensitive programming language. Thus, Rollno and rollno are two different identifiers in Python.

Example of valid and invalid identifiers

Valid: Myname, file123, Y2ad, date_2, _no

Invalid: 2rno, break, my.name, data-cs

Literals: Literals in Python can be defined as number, text, or other data that represent values to be stored in variables. Python allows several kinds of literals: (i) String (ii) Numeric (iii) Boolean (iv) Special literal (v) Literal collections

Example of String Literals

name = ‘Shekhar’             ,              fname = “shekhar”

Example of Integer Literal (Numeric Literal)

age = 15

Example of Special Literals

name = None

Escape Sequence in Python

Escape Sequence

Description

\\

Backslash (\)

\’

Single quote (‘)

\”

Double quote(“)

\a

ASCII Bell (BEL)

\b

ASCII Backspace (BS)

\f

ASCII Formeed (FF)

\n

ASCII Linefeed (LF)

\r

ASCII Carriage Return (CR)

\t

ASCII Horizontal Tab (TAB)

\v

ASCII Vertical Tab (VT)

\ooo

Character with octal value

\xhh

Character with hex value hh



Note: This is the notes of Chapter -4 PYTHON FUNDAMENTAL (FIRST PART). It is important for every students. By the help of these notes students can prepare for their Exam.


!!! THANK YOU !!!









Class 12 Informatics Practices 2026 Question Paper with Answers (Full Solution)

  CBSE Class 12 IP 2026 बोर्ड पेपर + Solutions 1. State whether the following statement is True or False: In Pandas Series, the Positional...