0% found this document useful (0 votes)
17 views

techtipnow_in

The document provides a comprehensive overview of Python programming concepts for Class 12 CBSE students, covering fundamentals such as variables, data types, operators, and control flow. It includes detailed explanations of strings, lists, tuples, and dictionaries, along with examples and operations associated with each data type. The notes aim to help students build a strong foundation in Python programming through practical examples and clear definitions.

Uploaded by

nandan.hariv
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

techtipnow_in

The document provides a comprehensive overview of Python programming concepts for Class 12 CBSE students, covering fundamentals such as variables, data types, operators, and control flow. It includes detailed explanations of strings, lists, tuples, and dictionaries, along with examples and operations associated with each data type. The notes aim to help students build a strong foundation in Python programming through practical examples and clear definitions.

Uploaded by

nandan.hariv
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

techtipnow

Python Revision Tour


Class 12 Notes | CBSE
Computer Science
2 Comments / Uncategorized / By Sanjay
Kumar

Python Revision Tour Class 12 Notes covers


Python Fundamentals of class 11 including
Variables, Operators, Input and Output, Flow
of control, Expressions, Type Casting, Strings,
List, Tuples, Dictionary. All the concepts are
explained with examples so that students can
build strong foundation in Python
Programming Fundamentals.

Contents [hide]

1 Getting Started with Python


2 Strings
3 List
4 Tuple
5 Dictionary

Getting Started with Python

Python is a General Purpose high level


Programming language used for developing
application softwares.

Features of Python

High Level
Free and Open Source
Case Sensitive
Interpreted
Plateform Independent
Rich library of functions
Dynamic
General Purpose

Working with Python

To write and run python programs we need


Python Interpreter also called Python IDLE.

Execution Mode

We can use Python Interpreter in two ways:

Interactive mode
Script mode

Interactive Mode

Instant execution of individual statement


Convenient for testing single line of code
We cannot save statements for future use

Script Mode

Allows us to write and execute more than


one Instruction together.
We can save programs (python script) for
future use
Python scripts are saved as file with
extension “.py”

How to execute or run python program

Open python IDLE


Click ‘File’ and select ‘New’ to open Script
mode
Type source code and save it
Click on ‘Run’ menu and select ‘Run
Module’

Python Keywords

These are predefined words which a


specific meaning to Python Interpreter.
These are reserve keywords
Keywords in python are case sensitive

Identifier

Identifiers are name used to identify a variable,


function or any other entities in a programs.

Rules for naming Identifier

The name should begin with an alphabet or


and underscore sign and can be followed
by any combination of charaters a-z, A-Z,
0-9 or underscore.
It can be of any length but we should keep
it simple, short and meaningful.
it should not be a python keyword or
reserved word.
We cannot use special symbols like !, @,
#, $, % etc. in identifiers.

Variables

It can be referred as an object or element


that occupies memory space which can
contain a value.
Value of variable can be numeric,
alphanumeric or combination of both.
In python assignment statement is used to
create variable and assign values to it.

Data types

These are keywords which determine the type of


data stored in a variable. Following table show
data types used in python:

Comments

These are statement ignored by python


interpreter during execution.
It is used add a remark or note in the
source code.
It starts with # (hash sign) in python.

Operators

These are special symbols used to perform


specific operation on values. Different types of
operator supported in python are given below:

Arithmetic operator
Relational operator
Assignment operator
Logical operator
Identity operator
Membership operator

Expressions

An expression is combination of different


variables, operators and constant which is
always evaluated to a value.
A value or a standalone variable is also
considered as an expression.

Example

56 + (23-13) + 89%8 – 2*3

Evaluation:

= 56 + (23 -13) + 89%8 – 2*3 #step1


= 56 + 10 + (89%8) – 2*3 #step2
= 56 + 10 + 1 – (2*3) #step3
= (56 + 10) + 1 – 6 #step4
= (66 + 1) – 6 #step5
= 67 – 6 #step6
= 61

Statement

A statement is unit of code that the python


interpreter can execute.

Example:

var1 = var2 #assignment


statement
x = input (“enter a number”) #input statement
print (“total = “, R) #output
statement

How to input values in python?

In python we have input() function for taking user


input.

Syntax:

Input([prompt])

How to display output in python?

In python we have print() function to display


output.

Syntax:

print([message/value])

Example:

Python program to input and output your


name

var = input(“Enter your name”)


print(“Name you have entered is “, var)

Example:

Addition of two numbers

Var1 = int(input(“enter no1”))


Var2 = int(input(“enter no2”))
Total = Var1 + Var2
Print(“Total = “, Total)

Type Conversion

Type conversion refers to converting one type of


data to another type.

Type conversion can happen in two ways:

Explicit conversion
Implicit conversion

Explicit Conversion

Explicit conversion also refers to type


casting.
In explicit conversion, data type conversion
is forced by programmer in program

Syntax:

(new_data_type) = (expression)
Explicit type conversion function

Example:

Program of explicit type conversion from float


to int

x = 12
y=5
print(x/y) #output – 2.4
print(int(x/y)) #output – 2

Program of explicit type conversion from


string to int

x = input(“enter a number”)
print(x+2) #output –
produce error “can only concatenate str to str
x = int(input(Enter a number”))
print(x+2) #output –
will display addition of value of x and 2

Implicit conversion

Implicit conversion is also known as


coercion.
In implicit conversion data type conversion
is done automatically.
Implicit conversion allows conversion from
smaller data type to wider size data type
without any loss of information

Example:

Program to show implicit conversion from int


to float

var1 = 10 #var1 is integer


var2 = 3.4 #var2 is float
res = var1 – var2 #res becomes float
automatically after subtraction
print(res) #output – 6.6
print(type(res)) #output –
class ‘Float’

Strings

String is basically a sequence which is


made up of one or more UNICODE
characters.
Character in string can be any letter, digit,
whitespace or any other symbol.
String can be created by enclosing one or
more characters in single, double or triple
quotes.

Examples:

Accessing characters in a string (INDEX)

Individual character in a string can be


accessed using indexes.
Indexes are unique numbers assigned to
each character in a string to identify them
Index always begins from 0 and written in
square brackets “[]”.
Index must be an zero, positive or negative
integer.
We get IndexError when we give index
value out of the range.

Negative Index

Python allows negative indexing also.


Negative indices are used when you want
to access string in reverse order.
Starting from the right side, the first
character has the index as -1 and the last
character (leftmost) has the index –n
where n is length of string.

Is string immutable?

Yes, string is immutable data type. The


content of string once assigned cannot be
altered than.
Trying to alter string content may lead an
error.

String operations

String supports following operations:

Concatenation
Repetition
Membership
Slicing

Concatenation

Concatenation refers to joining two


strings.
Plus (‘+’) is used as concatenation
operator.

Repetition

Repetition as it name implies repeat the


given string.
Asterisk (‘*’) is used as repetition operator.

Membership

Membership operation refers to checking a


string or character is part or subpart of an
existing string or not.
Python uses ‘in’ and ‘not in’ as membership
operator.
‘in’ returns true if the first string or
character appears as substring in the
second string.
‘not in’ returns true if the first string or
character does not appears as substring in
the second string.

Slicing

Extracting a specific part of string or


substring is called slicing
Subset occurred after slicing contains
contiguous elements
Slicing is done using index range like
string[start_index : end_index : step_value]
End index is always excluded in resultant
substring.
Negative index can also be used for slicing.

Traversing a String

Traversing a string refers to accessing each


character of a given string sequentially.
For or while loop is used for traversing a
string

String Functions

List

List is built in sequence data type in


python.
Stores multiple values
List item can be of different data types
All the items are comma separated and
enclosed in square bracket.
Individual item in a list can be accessed
using index which begins from 0.

Examples

Accessing elements in a List

Individual item in a list can be accessed


using indexes.
Indexes are unique numbers assigned to
each item in a list to identify them
Index always begins from 0 and written in
square brackets “[]”.

Example:

List is Mutable

Yes list is mutable.


Content of the list can be changed after it
has been created.

List operations

List supports following operations:

Concatenation
Repetition
Membership
Slicing

Concatenation

Concatenation refers to joining two List.


Plus (‘+’) is used as concatenation
operator.
Concatenating List with other data type
produces TypeErrors.

Example:

Repetition

Repetition as it name implies used to


replicate a list at specified no of times.
Asterisk (‘*’) is used as repetition operator.

Membership

Membership operation refers to checking


an item is exists in the list or not.
Python uses ‘in’ and ‘not in’ as membership
operator.
‘in’ returns true if the item specified
present in the list.
‘not in’ returns true if the item specified
present in the list.

Example:

Slicing

Extracting a subset of items from given list


is called slicing
Subset occurred after slicing contains
contiguous items.
Slicing is done using index range like
List[start_index : end_index : step_value]
End index is always excluded in resultant
subset of list.
Negative index can also be used for slicing.

Examples:

Traversing a List

Traversing a List refers to accessing each


item a given list sequentially.
for or while loop can be used for traversing
a list.

Examples:

List methods | List Functions

Nested List

One list appears as an element inside another list.

Example:

Tuple

Tuple is built in sequence data type in


python.
Stores multiple values
Tuple item can be of different data types
All the items are comma separated and
enclosed in parenthesis ‘()’.
Individual item in a Tuple can be accessed
using index which begins from 0.
In case of single item present in tuple, it
should also be followed by a comma.
A sequence without parenthesis is treated
as tuple by default.

Examples

Accessing elements in a Tuple

Individual item in a Tuple can be accessed


using indexes.
Indexes are unique numbers assigned to
each item in a Tuple to identify them
Index always begins from 0 and written in
square brackets “[]”.

Example:

Tuple is Immutable

Yes Tuple is Immutable.


Content of the Tuple cannot be changed
after it has been created.

Example:

Tuple operations

Tuple supports following operations:

Concatenation
Repetition
Membership
Slicing

Concatenation

Concatenation refers to joining two Tuple.


Plus (‘+’) is used as concatenation
operator.
Concatenation operator can also be used
for extending an existing tuple.

Example:

Repetition

Repetition as it name implies used to


repeat elements of a Tuple at specified no
of times.
Asterisk (‘*’) is used as repetition operator.

Membership

Membership operation refers to checking


an item exists in Tuple or not.
Python uses ‘in’ and ‘not in’ as membership
operator.
‘in’ returns true if the item specified
present in the Tuple.
‘not in’ returns true if the item specified
present in the Tuple.

Example:

Slicing

Extracting a subset of items from given


Tuple is called slicing
Subset occurred after slicing contains
contiguous items.
Slicing is done using index range like
Tuple[start_index : end_index : step_value]
End index is always excluded in resultant
subset of Tuple.
Negative index can also be used for slicing.

Examples:

Traversing a Tuple

Traversing a Tuple refers to accessing each


item a given Tuple sequentially.
for or while loop can be used for traversing
a Tuple.

Examples:

Tuple Methods and Built in Functions

Nested Tuple

One Tuple appears as an element inside another


Tuple.

Example:

Tuple Assignment

Tuple Assignment allows elements of tuple on the


left side of assignment operator to be assigned
respective values from a tuple on the right side.

Dictionary

Dictionaries are unordered collection of


items falls under mapping.
Stores data in form of key:value pair called
item.
Key is separated from its value by colon ‘:’
and items are separated by comma.
All items of dictionaries are enclosed in
curly bracket ‘{}’.
The keys in the dictionary must be unique
and should be of immutable data type.
The value can be repeated and of any data
type.

Creating a Dictionary

Accessing items in a Dictionary

Items of dictionary are accessed using


keys.
Each key of dictionary serve as index and
maps to a value.
If key is not present in dictionary, then we
get KeyError.

Examples

Dictionary is Mutable

Yes, Dictionary is Mutable as its content can be


changed after it has been created.

Adding a new item in Dictionary

Modifying an existing Item in Dictionary

Traversing a dictionary

Dictionary methods and built in functions

Previous Post

Next Post

Related Posts

18.What is missing data? 19. Why


is missing data filled in Dataframe
with some value? 20. Name the
function you can use for filling
missing data? 21. Name some
function to handle missing data.
Leave a Comment / Uncategorized / By Sanjay
Kumar

2. What will be the output of the


following code?
2. SELECT CONCAT
(CONCAT(‘Inform’, ‘atics’),
‘Practices’);
3. SELECT LCASE (’INFORMATICS
PRACTICES CLASS 11TH‘);
4. SELECT UCASE (’Computer
Studies‘);
5. SELECT CONCAT (LOWER
(‘Class’), UPPER (‘xii’));
Leave a Comment / Uncategorized / By Sanjay
Kumar

2 thoughts on “Python Revision Tour


Class 12 Notes | CBSE Computer
Science”

SWAGATA BANERJEE
MARCH 21, 2023 AT 1:02 AM

Sir, how can I get the pdf form of your notes

Reply

AARUSHI SINGH
APRIL 19, 2024 AT 12:08 AM

Fun stuff, thanks! :))

19 April 2024,
Friday,
5:37 A.M. :))

Reply

Leave a Comment
Your email address will not be published.
Required fields are marked *

Type here..

Name*

Email*

Website

Save my name, email, and website in this


browser for the next time I comment.

Post Comment »

Search... 

Categories

Artificial Intelligence

Boolean Algebra

Class 9 IT 402 Notes

Cloud Computing

Computer Fundamental MCQ

Computer Fundamentals

Computer Network

Computer Network MCQ

Computer Science Practicals

CS Class 11

CS Class 11 MCQ

CS Class 12 MCQ

CS Class 12 Tutorial

CSV File MCQ

CSV Files

CUET Computer Science Preparation

Cyber Crime

Cyber Safety

Cyber Security MCQ

Database Concept

DBMS MCQs

Emerging Trends

Find the Output

Internet

Internet MCQ

IOT

IP Class 11 MCQ

IP Class 11 Tutorial

IP Class 12 MCQ

IP Class 12 Tutorial

IP Practicals

IT 402 Class 10

IT 802 Class 11 MCQ

IT 802 Class 11 Tutorial

IT 802 Class 12 MCQ

IT 802 Class 12 Tutorial

Java Programming

KVS PGT Computer Science

Matplotlib Pyplot

NCERT Solutions

Open Office Tutorial

Operating System

Python Data Structure

Python DataFrame

python exception handling mcq

Python MCQ

Python Pandas

Python Pandas MCQ

Python Programs

Python Pyplot MCQ

Python Series

Python Tutorials

RDBMS

Societal Impact

Societal Impact MCQ

Spreadsheet

SQL MCQ

SQL Practicals

SQL Tutorials

Sumita Arora Solution

Uncategorized

About
Terms and Conditions
Private Policy
Refund Policy
Contact Us
Sitemap

| Copyright © 2025 techtipnow

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy