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

STRINGS AND STRING MANIPULATION · Part 7

Chapter 3: 4 · COMPUTER SCIENCE

are optional. If it is not given, python searched in whole string. Search is case sensitive. >>> str1="Raja Raja Chozhan" >>> print(str1.count('Raja')) >>> print(str1.count('r')) >>> prin t(str1.count('R')) >>> print(str1.count('a')) >>> print(str1.count('a', , )) >>> print(str1.count('a', )) ord(char ) Returns the ASCII code of the character.

>>> ch = 'A' >>> print(ord(ch)) >>> print( ord('B')) chr(ASII) Returns the character represented by a ASCII. >>> ch= >>> print(chr(ch)) a >>> print(chr( )) W . Membership Operators The ‘ in ’ and ‘ not in ’ operators can be used with strings to determine whether a string is present in another string. Therefore, these operators are called as Membership Operators.

str1=input ("Enter a string: ") str2="chennai" if str2 in str1: print ("Found") else: print ("Not Found") Output : Enter a string: Chennai G HSS, Saidapet Found Output : Enter a string: Govt G HSS, Ashok Nagar Not Found Example 12th Computer Chapter - - Example . Programs using Strings : str1 = input ("Enter a string: ") str2 = ' ' index=- for i in str1: str2 += str1[index] index -= print ("The given string = { } \n The Reversed string = { }".format(str1, str2)) if (str1==str2): print ("Hence, the given string is Palindrome") else: print ("Hence, the given is not a palindrome") Output : Enter a string: malayalam The given string = malayalam The Reversed string = malayalam Hence, the given string is Palindrome Output : Enter a string: welcome The given string = welcome The Reversed string = emoclew Hence, the given string is not a palindrome Example . . : Program to check whether the given string is palindrome or not * * * * * * * * * * * * * * * str1=' * ' i= while i<= : print (str1*i) i+= Output * * * * * * * * * * * * * * * Example .

. : Program to display the following pattern 12th Computer Chapter - - Strings and String Manipulation str1=input ("Enter a string:

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 →