Getting Started with Python Class 11 Notes

Teachers and Examiners (CBSESkillEduction) collaborated to create the Getting Started with Python Class 11 Notes. All the important Information are taken from the NCERT Textbook Computer Science (083) class 11.

Getting Started with Python Class 11 Notes

Python is a high-level, object-oriented programming language. Python is frequently considered as one of the simplest programming languages to learn for beginners. Python’s simple syntax prioritizes readability and makes it simple to learn, which lowers the cost of programme maintenance. Python’s support for modules and packages promotes the modularity and reuse of code in programmes. For all popular platforms, the Python interpreter and the comprehensive standard library are freely distributable and available in source or binary form.

Features of Python

  • Python is a high-level language. It is a free and open-source language.
  • It is an interpreted language, as Python programs are executed by an interpreter.
  • Python programs are easy to understand as they have a clearly defined syntax and relatively simple structure.
  • Python is case-sensitive. For example, NUMBER and number are not same in Python.
  • Python is portable and platform independent, means it can run on various operating systems and hardware platforms.
  • Python has a rich library of predefined functions.
  • Python is also helpful in web development. Many popular web services and applications are built using Python.
  • Python uses indentation for blocks and nested blocks.

Working with Python

We require a Python interpreter installed on our computer or we can utilise any online Python interpreter in order to create and run (execute) a Python programme. The Python shell is another name for the interpreter.

The Python prompt, represented by the symbol >>> in the screenshot above, indicates that the interpreter is prepared to accept commands.

Execution Modes

There are two ways to use the Python interpreter:
a) Interactive mode
b) Script mode

Interactive Mode

Programmers can quickly run the commands and try out or test code without generating a file by using the Python interactive mode, commonly known as the Python interpreter or Python shell. To work in the interactive mode, we can simply type a Python statement on the >>> prompt directly. It’s practical to test one line of code for immediate execution while working in interactive mode.

python shell
Script Mode

In the script mode, a Python programme can be written in a file, saved, and then run using the interpreter.
Python scripts are stored in files with the “.py” extension. Python scripts are saved by default in the Python installation folder.

script mode

Python Keywords

Keywords are reserved words. Each keyword has a specific meaning to the Python interpreter, and we can use a keyword in our program only for the purpose for which it has been defined. As Python is case sensitive, keywords must be written exactly.

python keyword


Identifiers are names used in programming languages to identify a variable, function, or other things in a programme. Python has the following guidelines for naming an identifier:
a. The name should begin with an uppercase or a lowercase alphabet or an underscore sign (_).
b. It can be of any length.
c. It should not be a keyword or reserved word.
d. We cannot use special symbols like !, @, #, $, %, etc.


A variable’s name serves as a program’s unique identifier (identifier). In Python, the term “variable” refers to an object, which is a thing or things that is kept in memory. A variable’s value can be a string, such as “b,” or a number, such as “345,” or any combination of alphanumeric characters (CD67). In Python, we can create new variables and give them particular values by using an assignment statement.

gender = ‘M’
message = “Keep Smiling”
price = 987.9


In the source code, comments are used to add remarks or notes. The interpreter doesn’t carry out comments. They are included to make the source code simpler for individuals to understand. comments always start from #.

#Add your python comments

Everything is an Object

Python treats every type of object, including variables, functions, lists, tuples, dictionaries, sets, etc., as an object. Each item belongs to a particular class. An integer variable, for instance, is a member of the integer class. An item is a physical thing. A collection of various data and functions that work with that data is an object.

Data Types

In Python, each value corresponds to a certain data type. A variable’s data type describes the kinds of data values it can store and the types of operations it can execute on that data. The data types that Python.

data type in python

Only numerical values are stored in the Number data type. Three other categories are used to further categories it: int, float, and complex.



An ordered group of things, each of which is identified by an integer index, is referred to as a Python sequence. Strings, Lists, and Tuples are the three different forms of sequence data types that are available in Python.

  1. String – A string is a collection of characters. These characters could be letters, numbers, or other special characters like spaces. Single or double quotation marks are used to surround string values for example, ‘Hello’ or “Hello”).
  2. List – List is a sequence of items separated by commas and the items are enclosed in square brackets [ ]. example list1 = [5, 3.4, “New Delhi”, “20C”, 45]
  3. Tuple – A tuple is a list of elements enclosed in parenthesis and separated by commas ( ). Compared to a list, where values are denoted by brackets [], this does not. We cannot alter the tuple once it has been formed. example tuple1 = (10, 20, “Apple”, 3.4, ‘a’)

A set is a group of elements that are not necessarily in any particular order and are enclosed in curly brackets. The difference between a set and a list is that a set cannot include duplicate entries. A set’s components are fixed once it is constructed. examle set1 = {10,20,3.14,”New Delhi”}


A unique data type with only one value is called None. It is employed to denote a situation’s lack of worth. None is neither True nor False, and it does not support any special operations (zero). example myVar = None


Python has an unordered data type called mapping. Python currently only supports the dictionary data type as a standard mapping data type.

  1. Dictionary – Python’s dictionary stores data elements as key-value pairs. Curly brackets are used to surround words in dictionaries. Dictionary use enables quicker data access. example, dict1 = {‘Fruit’:’Apple’, ‘Climate’:’Cold’, ‘Price(kg)’:120}

Mutable and Immutable Data Types

Once a variable of a certain data type has been created and given values, Python does not enable us to modify its values. Mutable variables are those whose values can be modified after they have been created and assigned. Immutable variables are those whose values cannot be modified once they have been created and assigned.

classification of data types

Deciding Usage of Python Data Types

When we need a straightforward collection of data that can be modified frequently, lists are chosen.
For example, it is simple to update a list of student names when some new students enrol or some students drop out of a class. When there is no requirement for data modification, we use tuples. For instance, the names of the months of a year.


A specific mathematical or logical operation on values is performed using an operator. Operands are the values that the operators manipulate. As an illustration, the operands of the phrase 10 + num are the number 10 and the variable num, and the operator is the plus symbol (+).

Arithmetic Operators

The four fundamental arithmetic operations, as well as modular division, floor division, and exponentiation, are all supported by Python’s arithmetic operators.

%Modulus//Floor Division**Exponent
Relational Operators

A relational operator establishes the relationship between the operands by comparing their values on either side.

==Equals to!=Not equal to>Greater than<Less than
>=Greater than
or equal to
<=Less than or
equal to
Assignment Operators

Assignment operator assigns or changes the value of the variable on its left.

=Assigns value from right-side operand to left-
side operand
+=It adds the value of right-side operand to the
left-side operand and assigns the result to the
left-side operand
Note: x += y is same as x = x + y
-=It subtracts the value of right-side operand from
the left-side operand and assigns the result to
left-side operand
Note: x -= y is same as x = x – y
*=It multiplies the value of right-side operand
with the value of left-side operand and assigns
the result to left-side operand
Note: x *= y is same as x = x * y
/=It divides the value of left-side operand by the
value of right-side operand and assigns the
result to left-side operand
Note: x /= y is same as x = x / y
%=It performs modulus operation using two
operands and assigns the result to left-side
Note: x %= y is same as x = x % y
//=It performs exponential (power) calculation on
operators and assigns value to the left-side
Note: x **= y is same as x = x ** y
Logical Operators

Python is compatible with three logical operators. Only lower case letters may be used to write these operators (and, or, not).

andLogical ANDorLogical ORnotLogical NOT
Identity Operators

Identity operators are used to determine whether or not a variable’s value belongs to a particular type. To determine whether two variables are referring to the same object or not, identity operators can also be utilised. Two identity operators are available.

isEvaluates True if the variables on either
side of the operator point towards the same
memory location and False otherwise.
var1 is var2 results to True if id(var1) is
equal to id(var2)
is notEvaluates to False if the variables on
either side of the operator point to the same
memory location and True otherwise. var1
is not var2 results to True if id(var1) is not
equal to id(var2)
Membership Operators

Membership operators are used to check if a value is a member of the given sequence or not.

inReturns True if the variable/value is found in the
specified sequence and False otherwise
not inReturns True if the variable/value is not found in
the specified sequence and False otherwise


A mixture of constants, variables, and operators is referred to as an expression. An expression will always yield a value. An expression can either be a value or a standalone variable, but a standalone operator is not an expression. Below are a few instances of legitimate expressions.

100numnum – 20.43.0 + 3.1423/3 -5 * 7(14 -2)“Global” + “Citizen”

Precedence of Operators

The order in which an operator is applied in an expression where there are several types of operators is determined by its precedence. The operator with a higher precedence is evaluated before the operator with a lower precedence.

Order of
1**Exponentiation (raised to the power)
2~ ,+, –Complement, unary plus and unary minus
3,/, %, //Multiply, divide, modulo and floor division
4+, –Addition and subtraction
5<= ,< ,> ,>=Relational operators
6== ,!=Equality operators
7=, %=, /=, //=, -=, +=, *=, **=Assignment operators
8is, is notIdentity operators
9in, not inMembership operators
10not, or, andLogical operators


In Python, a statement is a unit of code that the Python interpreter can execute.

x = 4 #assignment statement
cube = x ** 3 #assignment statement
print (x, cube) #print statement
4 64

Input and Output

The user is prompted to provide data using the input() function. All user input is accepted as strings. Although the input() function only accepts strings, the user may enter either a number or a string. input() has the following syntax:

input ([Prompt])

Prompt is an optional string that we could choose to display on the screen before accepting input. When a prompt is specified, it is first shown to the user on the screen before data entry is allowed. The input() function accepts the text entered directly from the keyboard, turns it to a string, and then assigns it to the variable to the left of the assignment operator (=). Pressing the enter key ends data entry for the input function.

fname = input(“Enter your first name: “)
Enter your first name: Arnab
age = input(“Enter your age: “)
Enter your age: 19

Python’s print() method outputs data to the screen, which is the standard output device. Before printing the expression, the print() function evaluates it.

print(“I” + “love” + “my” + “country”)Ilovemycountry
print(“I’m”, 16, “years old”)I’m 16 years old

Type Conversion

An object can be converted from one data type to another using typecasting, also known as type conversion. It is employed in computer programming to guarantee that a function processes variables appropriately. Converting an integer to a string is an illustration of typecasting. There are two type of conversion –

  1. Explicit Conversion
  2. Implicit Conversion
Explicit Conversion

Data type conversion that occurs because the programmer actively implemented it in the programme is referred to as explicit conversion, also known as type casting. An explicit data type conversion can take the following general forms:

(new_data_type) (expression)

Type Conversion between Numbers and Strings

priceIcecream = 25
priceBrownie = 45
totalPrice = priceIcecream + priceBrownie
print(“The total is Rs.” + totalPrice )

Implicit Conversion

When Python converts data types automatically without a programmer’s instruction, this is referred to as implicit conversion, also known as coercion.

Implicit type conversion from int to float

num1 = 10 #num1 is an integer
num2 = 20.0 #num2 is a float
sum1 = num1 + num2 #sum1 is sum of a float
and an integer


A programmer’s errors can prevent a programme from running properly or from producing the intended results. Debugging is the process of finding and fixing these flaws, sometimes referred to as bugs or errors, in a software. Program errors can be categorised as follows:

  1. Syntax errors
  2. Logical errors
  3. Runtime errors
Syntax Errors

The syntax of Python is determined by its own rules. Only correctly syntactical statements—those that adhere to Python’s rules—are interpreted by the interpreter. The interpreter displays any syntax errors and terminates the execution at that point. For example, parentheses must be in pairs, so the expression (10 + 12) is syntactically correct, whereas (7 + 11 is not due to absence of right parenthesis.

Logical Errors

A programme defect that results in improper behaviour is known as a logical error. A logical mistake results in an undesirable output without immediately stopping the program’s execution. It can be challenging to spot these issues because the programme interprets correctly even though it contains logical faults.

For example, if we wish to find the average of two numbers 10 and 12 and we write the code as 10 + 12/2, it would run successfully and produce the result 16. Surely, 16 is not the average of 10 and 12. The correct code to find the average should have been (10 + 12)/2 to give the correct output as 11.

Runtime Error

A runtime fault results in an unexpected programme termination while it is running. When a statement is syntactically correct but unable to be executed by the interpreter, it is said to have a runtime error. Runtime errors do not show up until the programme has begun to run or execute.

For example, we have a statement having division operation in the program. By mistake, if the denominator entered is zero then it will give a runtime error like “division by zero”.

Computer Science Class 11 Notes
Computer Science Class 11 MCQ
Computer Science Class 11 NCERT Solutions