CS Art Integrated Progect
CS Art Integrated Progect
CS Art Integrated Progect
Acknowledgement
Submitted by : shresth saini
Class : 11-A
Roll No : 11110
Topic : Strings
Submitted to : Namrata Mam
STRINGS IN PYTHON
● In python, a consecutive sequence of characters, which are enclosed by single (‘’) or
double (“”) quotes is known as strings.
● Strings are immutable and hence you cannot change the individual letters of string
using assignment operators.
ACCESSING CHARACTERS IN A STRING
● Strings in python are stored as individual characters i.e. indexed wise. The index by default
starts with 0.
str=
● So, here ‘H’ will be represented by str[0] or str[-11], ‘e’ will be represented by either str[1] or
str[-10] and so on.
STRING OPERATORS
● Concatenation operator (+) : This operator concatenates two different strings.
● Repitition operator (*) : This operator requires two types of operands – a string and a number. It
replicates the given string.
● Membership operator: “in” & “not in” : Membership operator is used to searching whether
the specific character is part/member of a given input python string.
STRING SLICING
● String slicing operator “[]” : Characters from a specific index of the string can be accessed with
the string[index] operator. The index is interpreted as a positive index starting from 0 from the left
side and a negative index starting from -1 from the right side.
Syntax - string[start:end:step]
STRING METHODS AND BUILT IN FUNCTIONS
Method Discription
.
len() Returns the length of the string
capitalze() Converts the first character to upper case
split() Splits the string at the specified separator, and returns a list