12th Standard Syllabus & Materials
12th Standard
TN 12th Computer Applications மின்னணு தரவு பரிமாற்றம் Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications மின் - வணிக பாதுகாப்பு அமைப்புகள் Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications மின்னணு செலுத்தல் முறைகள் Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications மின் - வணிகம் Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications திறந்த மூல கருத்துருக்கள் Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications வலையமைப்பு வடமிடல் Sample Question Papers Study Material - QB365 Set A

Published on: 05/09/2022
QB365 provides a detailed and simple solution for every Possible Creative Questions in Class 12 Computer Science Subject - Strings and String Manipulations , English Medium. It will help Students to get more practice questions, Students can Practice these question papers in addition to score best marks.
Download Tamil Nadu 12th Standard Computer Science question papers, model tests, one-mark questions, important questions, and public exam papers in PDF format. Free study materials and answer keys for TN State Board students.
Questions + Answers key
Take MCQ Computer Science Test

1.
Write a program to remove vowels from the given string.
2.
Explain in detail about built-in function.
3.
Explain in detail about escape sequences in Python.
4.
Explain in detail about string formatting operators.
5.
Explain in detail about modification and deletion of a string with an example.
6.
Explain how will you create and access characters in a string with an example?
7.
Write a python program to display the number of vowels and consonants in the given string.
8.
Write a python program to print the following pattern
*
**
***
****
*****
9.
Write a python program to check whether the given string is palindrome or not.
1.
def rem_ vowels (s):
temp_str ="
for i in s:
if i in "aAeEiOoOuU":
pass
else:
temp_str + =i
print("The string without vowels:",temp_str)
str1 = input ("Enter a string")
rem_vowels(str1)
Output:
Enter a string: Mathematical functions of Computer Science
The string without vowels: Mthmtcl fndtns fcmptr Scnc
2.
| Syntax | Description | Example |
| 1. len(str) | Returns the length of the string | >>>A = "Corporation" >>> print (len(A)) 11 |
| 2. capitalize() | Used to capitalize the first character of the string. | >>> city = "Chennai" >>>print(city.capitalize( ) ) Chennai |
| 3. center(width, fillchar) | Returns a string with the original string centered to a total of width columns and filled with fillchar in columns that do not have characters |
>>> str1 = "Welcome" >>>print(str1.center (15, *')) *** Welcome*** |
| 4. find(sub[,start [,end]) |
The function is used to search the first occurrence of the sub-string in the given string. it returns the index at which the substring starts. It returns -1 if the substring does not occur in the string. |
>>>strl= 'mammals' >>>strl.find ('ma') 0 On omitting the start parameters, the function starts the search from the beginning. >>>str1.find('ma'. 2) 3 >>>str1.find('ma'. 2,4) -1 Displays - 1, because the substring could not be found between the index 2 and 4-1. >>> str1. find ('ma',2,5) 3 |
| 5. isalnum() | Returns True if the string contains only letters and digits. It returns false. If the string contains any special character like, @, #, *, etc |
>>> str1='Save Earth' >>>str1.isalnum( ) false The function returns false as space is an alphanumeric character. >>>'Save/Earth' isalnum( ) True. |
| 6. isalpha() | Returns True if the string contains only letters. Otherwise return false |
>>> 'Click 123'.isalpha( ) False. >>>'Python'.isalpha( ) True |
| 7. isdigit() | Returns True if the string contains only numbers. Otherwise, it returns False. | >>> str1='Save Earth' >>> print(str1.isdigit( )) False |
| 8. lower() | Returns the exact copy of the string with all the letters in lowercase. |
>>> str1= "SAVE EARTH', >>> print(str1.lower( )) save earth |
| 9. is lower() | Returns True if the string is in lowercase | >>> str1='Welcome', >> print (strl.islower( )) True |
| 10. isupper() | Returns True if the string is in uppercase | >>> str1='welcome' >>> print(str1.isupper( )) False |
| 11. upper() | Returns the exact copy of the string with all letters in uppercase | >>> strl='Welcome' >>> print (str.upper( )) WELCOME |
| 12. title() | Returns a string in title case | >>>str1='education department' >>> print(str1.title ( )) Education Department |
| 13. swapcase() | It will change case of every character to its opposite case vice-versa. |
>>> str1= "tAmilNaDu" >>> print(str1.swapcase( )) TaMIL nAdu |
| 14. count(str,beg,end) | Returns the number of substrings occurs within the given range. Remember that substring may be as single character. Range arguments are optional. If it is not given, python searched in whole string. Search is case-sensitive. |
>>>str1= "Raja Raja chozhan" >>>print(str1.com('Raja')) 2 >>>print(str1.count('r')) 0 >>>print (str1.count('R') ) 2 >>>print (str1.count('a')) 5 >>>print (str1.count('a',0,5 )) 2 >>>print(str1.count('a',11)) 1 |
| 15. ord (char) | Returns the ASCII code of character. |
>>> ch = 'A' >>>print(ord (ch)) 65 >>>print (ord ('B')) 66 |
| 16. chr(ASII) | Returns the character represented by a ASCII | >>>ch =97 >>>print(chr(ch)) a >>>print(chr(87)) w |
3.
Escape sequences starts with a backslash and it can be interpreted differently. When we have use single quote to represent a string, all the single quotes inside the string must be escaped. Similar is the case with double quotes.
Example:
# String within triple quotes to display a string with single quote.
> > > (""They said,"What's there?"")
They said, "What's there?"
# String within single quote to display a string with single quote using escape sequence.
> > > print(""They said,"What's there?"")
They said, "What's there?"
# String within double quote to display a string with single quote using escape sequence.
> > > print("They said,\"what's there?\"")
He said, "What's there?"
| Escape sequence | Description |
| 1. \newline | Backslash and newline ignored |
| 2. \\ | Backslash |
| 3. \' | Single quote |
| 4. \" | Double quote |
| 5. \a | ASCII Bell |
| 6. \b | ASCII Backspace |
| 7. \f | ASCII Form feed |
| 8. \n | ASCII Line feed |
| 9. \r | ASCII carriage Return |
| 10. \t | ASCII Horizontal Tab |
| 11. \v | ASCII Vertical Tab |
| 12. \000 | Character with octal value 000 |
| 13. \x HH | Character with hexadecimal value HH |
4.
The string formatting operator is one of the most exciting features of python. The formatting operator % is used to construct strings, replacing parts of the strings with the data stored in variables.
Syntax:
("String to be display with %val1 and %val2" %(val1,val2))
Example:
name = "Rajarajan"
mark = 98
print("Name:%s and Mark:%d"%(name,mark))
Output:
Name: Rajarajan and Marks: 98
| Format characters | Usage |
| 1. %c | Character |
| 2. %d or %i | Signed decimal integer |
| 3. %s | String |
| 4. %u | Unsigned decimal integer |
| 5. %o | Octal integer |
| 6. %x or %x | Hexadecimal integer (lower case x refer a-f; upper case X refers A-F) |
| 7. %e or %E | Exponential notation |
| 8. %f | Floating point numbers |
| 9. %g or %G | Short numbers in floating point or exponential notation |
5.
Strings in Python are immutable. That means once we define a string, modifications or deletion is not allowed. If we want to modify the string, a new string value can be assign to the existing string variable.
Example:
>>>str1 = "How are you"
>>>str1 [0] = "A"
Traceback (most recent call last)
File "<pyshell # 1>", line 1, in <module>
str1 [0] = "A"
Output:
Type Error: 'str' object does not support item assignment
In the above example, string variable str1 has been assigned with the string "How are you" in statement 1. In the next statement, we try to update the first character of the string with character 'A' But python will not allow the update and it shows a Type error.
To overcome this problem, we can define a new string value to the existing string variable. Python completely overwrite a new string on the existing string.
Example:
>>>str1 = "How are you"
>>>print(str1)
How are you
>>>str1 = "How about you"
>>>print(str1)
How about you
Usually Python does not support any modification in its strings. But, it provides a function replaceQ to change all occurrences of a particular character in a string.
General format of replace function:
replace ("Char1", "Char2")
The replace function replaces all occurrences of char1 with char2.
Example:
>>>str1 = "How are you"
>>>print(str1)
How are you
>>>print(str1.replace("o","e"))
How are yeu.
Similar as modification, python will not allow deleting a particular character in a string. Whereas you can remove entire string variable using del command.
codeines to delete a particular character in a string:
>>>str1 = "How are you"
>>>del str[2]
Traceback (most recent call last):
File "<pyshell #7)", linel, in <module>
del str1[2]
Output:
TypeError: 'str' object doesn't support item deletion.
>>>str1 = "How about you"
>>>print(str1)
How about you
>>del str1
>>>print(str1)
Traceback (most recent call last):
File"< pyshell #14)", linel, in <module>
print(str1)
Output:
Name Error: name 'str1' is not defined.
6.
String is a data type in python, which is used to handle array of characters. String is a sequence of unicode characters that may be a combination of letters, numbers or special symbols enclosed within single, double or even triple quotes.
Example:
'Welcome to learning python'
"Welcome to learning python"
""Welcome to learning python""
In Python, strings are immutable, it means once we define a string, it cannot be changed during execution.
Creating Strings:
A string in Python can be created using single or double or even triple quotes. String in single quotes cannot hold any other single quoted character in it, because the compiler will not recognize where to start and end the string. To overcome this problem, we have to use double quotes. Strings which contains double quotes should be define within triple quotes. Defining strings within triple quotes also allows creation of multiline strings.
Once we define a string, Python allocate an index value for its each character. These index values are otherwise called as subscripts which are used to access and manipulate the strings. The subscript can be positive or negative integer numbers.
The positive subscript 0 is assigned to the first character and n-1 to the last character, where n is the number of characters in the string. The negative index assigned from the last character to the first character in reverse order begins with - 1.
Example:
| String | S | C | H | O | O | L |
| Positive subscript | 0 | 1 | 2 | 3 | 4 | 5 |
| Negative subscript | -6 | -5 | -4 | -3 | -2 | -1 |
Program to access each character with its positive subscript of a given string:
Str1 = input("Enter a string:")
index = 0,
for i in str1
print("Subscript[",index;"]",i)
index+=1
Output:
Enter a string: Welcome
Subscript [0]: W
Subscript [1]: e
Subscript [2]: I
Subscript [3]: c
Subscript [4]: o
Subscript [5j: m
Subscript [6]: e
Program to access each character with its negative subscript of a giving string:
str1 = input("Enter a string")
index = -1
while index>=-(len(str1)):
print("Subscript[",index,"]:" + str1 [index])
index + = -1
Output:
Enter a string: Welcome
Subscript [-1]: e
Subscript [-2]: m
Subscript [-3]: o
Subscript l-4): c
Subscript [-5]:l
Subscript [-5]: e
Subscript [-71:W
7.
str1=input ("Enter a string:")
str2="aAeEiloOuU"
v,c=0,0
for i in str1:
if i in str2:
v+=1
else:
c+=1
print ("The given string contains {} vowels and {} consonants".format(v.c))
Output:
Enter a string: Tamilnadu School Education.
The given string contains 11 vowels and 15 consonants.
8.
strl=' * '
i=1
while i< = 5:
print (strl*i)
i+=1
9.
str1 = input ("Enter a string:")
str2 ="
index=-1
for i in str1:
str2 += str1[index]
index -=1
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:1
Enter a string: malayalam
The given string = malayalam
The Reversed string = malayalam
Hence, the given string is Palindrome
Output: 2
Enter a string: welcome
The given string = welcome
The Reversed string = emoclew
Hence, the given string is not a palindrome
12th Standard Syllabus & Materials
12th Standard
TN 12th Computer Applications களப்பெயர் முறைமை (DNS) Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications வலையமைப்பு எடுத்துக்காட்டுகள் மற்றும் நெறிமுறைகள் Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications கணினி வலையமைப்பு ஓர் அறிமுகம் Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications PHP-உடன் MySQL-ஐ இணைத்தல் Sample Question Papers Study Material - QB365 Set A
Tamilnadu Stateboard 12th Standard Subjects

Maths

Chemistry

Physics

Biology

Computer Science

Business Maths and Statistics

Economics

Commerce

Accountancy

History

Computer Applications

Biology

Computer Technology

Computer Applications

Computer Science

Business Maths and Statistics

Commerce

Economics

Maths

Chemistry

Physics

Computer Technology

History

Accountancy

Tamil

English

French
Tamilnadu Stateboard Standards