📖 generic · 12th TN - English Medium · COMPUTER SCIENCE · Page 120definition

STRINGS AND STRING MANIPULATION · Part 8

Chapter 3: 4 · COMPUTER SCIENCE

") str2="aAeEiIoOuU" v,c= , for i in str1: if i in str2: v+= elif i.isalpha(): c+= print ("The given string contains { } vowels and { } consonants".format(v,c)) Output Enter a string: Tamilnadu School Education The given string contains vowels and consonants Example . . : Program to display the number of vowels and consonants in the given string str1="ABCDEFGH" str2="ate" for i in str1: print ((i+str2),end='\t') Output Aate Bate Cate Date Eate Fate Gate Hate Example . .

: Program to create an Abecedarian series. (Abecedarian refers list of elements appear in alphabetical order) def (s): ='' for i in s: if i in "aAeEiIoOuU": pass else: +=i print ("The string without vowels: ", ) str1= input ("Enter a String: ") (str1) Output Enter a String: Mathematical fundations of Computer Science The string without vowels: Mthmtcl fndtns f Cmptr Scnc Example . . : Program that accept a string from the user and display the same after removing vowels from it 12th Computer Chapter - - def count(s, c): c1= for i in s: if i == c: c1+= return c1 str1=input ("Enter a String: ") ch=input ("Enter a character to be searched: ") cnt=count (str1, ch) print ("The given character {} is occurs {} times in the given string".format(ch,cnt)) Out Put Enter a String: Software Engineering Enter a character to be searched: e The given character e is occurs times in the given string Example .

. : Program that count the occurrences of a character in a string • String is a data type in python. • Strings are immutable, that means once you define string, it cannot be changed during execution. • Defining strings within triple quotes also allows creation of multiline strings.

• In a String, python allocate an index value for its each character which is known as subscript. • The subscript can be positive or negative integer numbers. • Slice is a substring of a main string. • Stride is a third argument in slicing operation.

• Escape sequences starts with a backslash and it can be interpreted differently. •

Related topics

Have a question about this topic?

Get an AI answer grounded in your actual textbook — with the exact page reference.

Ask AI about this topic →