PPT CLASS XII COMPUTER SCIENCE CH-1 Python Revision PPT
PPT CLASS XII COMPUTER SCIENCE CH-1 Python Revision PPT
• We know that data types are nothing but the type of data we use to the variable,
method etc.
• We have following data types in Python.
1. Number
2. String
3. Boolean
4. List
5. Tuple
6. Set
7. Dictionary
Number
In Python we use number data type to store numeric value.
• Integer – Whole number without fraction parts ex: 1, 2 etc. Use 32 bits to store
value.
• Long integer – It store larger integer number. Use 32 bits to store value.
• Floating Point – It is a positive or negative real numbers with a
decimal point.
• Complex – Complex numbers are combination of a real and imaginary part.
Complex numbers are in the form of X+Yj, where X is a real part and Y
is imaginary part.
Input : a = complex(5) Output : (5+0j)
print(a)
String
• A string is a sequence of characters. In python we can create string
using single (' ') or double quotes (" ").Both are same in python.
Ex : - Input :
str='computer science’
print('str-', str) # print string
Output :
str- computer science
String Method
Method Description
Capitalize() Returns a copy of string with its first character as capita
Find() Returns the lowest index in the string
Isalnum() Returns true if the character in the string are alphanumeric
Isalpha() Returns true if the character in the string are alphabetic
Isdigit() Returns true if the character in the string are digit
Islower() Returns true if all the cased characters in the string are lowercase
Isupper() Returns true if all the cased characters in the string are uppercase
Title() Returns True if the string is in title case
Swapcase() Returns a copy of the string with uppercase character converted to lowercase and vice
versa
Partition() Splits the string at the first occurrence of argument
String Methods contd..
Method Description
Isspace() Returns true if there are only whitespace character in the string
Count() Returns the number of non-overlapping occurrence of substring in the given string
lstrip Returns a copy of the string with leading characters removed
rstrip Returns a copy of the string with trailing characters removed
Startswith() Returns true if string starts with the argument otherwise return false
Endswith() Returns true if string ends with the argument otherwise return false
• Dictionary • String
• List • Integer
• Tuples
• Booleans
• Floating Point
Arithmetic Operators
Operators are special symbols in Python that carry out arithmetic or logical
computation. The value that the operator operates on is called the operand.
Arithmetic operators Used for mathematical operation
Operator Meaning Example
+ Add two operands x + y +2
- Subtract right operand from the left x - y -2
* Multiply two operands x*y
/ Divide left operand by the right one x/y
% Modulus - remainder of the division x%y
// Floor division - division that results into whole number x // y
** Exponent - left operand raised to the power of right x**y
Comparison operators - Used to compare values
Operator Meaning Example
Input Output
x=1 Matched
y=2
if(x==1 and y==2):
print(‘Matched')
if-else Statements
• If-else statement executes some code if the test expression is true
and some other code if the test expression is false.
Input Output
a=10 less than 100
if(a < 100):
print(‘less than 100')
else:
print(‘more than equal
100')
Nested if-else statement
The nested if...else statement allows you to check for multiple test
expressions and execute different codes for more than two conditions.
Input Output
Input Output
for letter in ‘rajeev': r
if letter == 'e' or letter == ‘a': J
continue v
print( letter)
Input Output
for letter in 'rajeev': Current Letter : a
if letter == 'a' or letter == 'j':
break
print('Current Letter :', letter)
Pass Statement: We use pass statement to write empty loops. Pass is also used for empty control statements,
function and classes.
for letter in 'rajeev': Last Letter : v
pass
print('Last Letter :', letter)
SCHOOL OF EDUCATORS
You will get Pre- Board Papers PDF, Word file, PPT, Lesson Plan, Worksheet, practical tips and Viva
questions , reference books , smart content , curriculum , syllabus , marking scheme , toppers answer
scripts , revised exam pattern , revised syllabus , Blue Print etc. here .Join Your Subject WhatsApp
Group.
Kindergarten
Teachers Jobs
Rules & Regulations of the Group
1. No introduction
2. No Good Morning/Any wish type message
3.No personal Chats & Messages
4. No Spam
5. You can also ask your difficulties here.
For teachers, Artham resource materials include lesson plans, instructional guides,
assessment tools, professional development materials, and teaching aids. These
materials are well researched and created according to 2023-24 NEP and NCERT
guidelines.
For students, resource materials can include textbooks, study guides, homework
assignments, reference books, online learning platforms, and educational videos. These
materials can be obtained from school libraries, educational publishers, online
resources, and teachers.
Both teachers and students can also benefit from Artham educational resources which
are free and openly licensed educational materials that can be used and shared for
teaching and learning. Artham resource material include textbooks, courses, lesson
plans, and multimedia resources that are available online.
Teachers and students can also purchase these resources from the links provided with
every resource.