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

CH2. Python Revision Tour - II: Cbse - Class - Xii Computer Science With Python (New) (Subject Code:083)

This document discusses strings in Python. It defines strings as sequences of characters enclosed in single, double, or triple quotes. Strings can be indexed and traversed. Operators like + (concatenation), * (replication), in, not in, ==, !=, <, <=, >, >= can be used on strings. String slicing is getting a substring. Built-in functions manipulate strings, like upper(), lower(), isupper(), islower(), count(), find(), len(). Homework is to write a program printing statistics of a line, like number of alphabets, uppercase alphabets, lowercase alphabets, and digits.

Uploaded by

vvs. t.s3164
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)
48 views

CH2. Python Revision Tour - II: Cbse - Class - Xii Computer Science With Python (New) (Subject Code:083)

This document discusses strings in Python. It defines strings as sequences of characters enclosed in single, double, or triple quotes. Strings can be indexed and traversed. Operators like + (concatenation), * (replication), in, not in, ==, !=, <, <=, >, >= can be used on strings. String slicing is getting a substring. Built-in functions manipulate strings, like upper(), lower(), isupper(), islower(), count(), find(), len(). Homework is to write a program printing statistics of a line, like number of alphabets, uppercase alphabets, lowercase alphabets, and digits.

Uploaded by

vvs. t.s3164
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/ 19

CH2.

Python Revision Tour - II


CBSE –CLASS – XII
COMPUTER SCIENCE WITH PYTHON(NEW)
(SUBJECT CODE :083)
Objective 2

Strings in Python
Lists in Python
Tuples in Python
Dictionaries in Python
Sorting- bubble sort & insertion sort
3
Strings in Python 4

Sequence of characters enclosed by single, double or triple quote is


referred as “string”
- ‘Gubert’
- “Gubert”
- ‘’’Gubert’’’
String is sequence of characters, each character having unique position
or index
F Index 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Character W E L C O M E T O I N D I A
BIndex -16 -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1
Item Assignment NOT Supported 5
Traversing A String 6

Iterating through a element of String , one character at a time.


Each character are accessible through unique index.
String Operators 7

Basic Operators [ +, *, String Slicing]


Membership Operators [ in , not in]
Comparison Operators [ == , !=, < , <= , >, >=]
Basic Operators (+) 8

+operator is Concatenation Operator


*operator is Replication Operator
Note:
Booth operands must be same type.
Basic Operators (*) 9

+operator is Concatenation Operator


*operator is Replication Operator
Note:
one operand is string and
another must be an integer.
Membership Operators 10

Operator Working
in Returns true if character /substring occurs in a given string, otherwise false.
not in Returns false if character /substring occurs in a given string, otherwise true.
Comparison Operators 11

All relational Operators are comparison operator (<, <=,>, >=,==,!=).


In case of characters Uppercase letters are considered smaller than the
lowercase letters.
Python compares two strings through relational operators using character by
character comparison of their Unicode Values.
Ordinal/ Unicode Value 12
String Slice 13

String slice is the part of a String containing some contiguous


character from thestring.
For Example ‘or’ , ‘corpor’, ‘tion’, ‘n’ are slice of String ‘corporation’.
String Function / Methods 14

Python offers many built-in functions for string manipulation


String Function / Methods 15
String Function / Methods 16
String Function / Methods 17
String Function / Methods 18
H.W Program 19

W.P.P that reads a line and prints its statistics like:


No of Alphabets:
No of Upper Case Alphabets:
No of Lower Case Alphabets:
No of Digits:

Worksheet-2

You might also like