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: 14/10/2019
Strings and String Manipulations
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 note about count( ) function in python.
2.
What is the use of format( )? Give an example.
3.
What will be the output of the given python program?
str1 = "welcome"
str2 = "to school"
str3 = str1[:2] + str2[len(str2)-2:]
print (str3)
4.
Write a short about the followings with suitable example:
(a) capitalize( )
(b) swapcase( )
5.
Write a Python program to display the given pattern
C O M P U T E R
C O M P U T E
C O M P U T
C O M P U
C O M P
C O M
C O
C
6.
Write a python program to display the number of vowels and consonants in the given string.
7.
Write a python program to print the following pattern
*
**
***
****
*****
8.
Write a python program to check whether the given string is palindrome or not.
9.
Explain about string operators in python with suitable example.
1.
| Syntax | Description | Example |
| count (str,beg,end) | Returns the number of substrings Occurs within the given range. Remember that substring may be a single character. Range (beg and end) arguments are optional. If it is not given, python searched in whole string. Search is case sensitive. | >>>str1="Raja Raja Chozhan" >>>print(str1.count("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 |
2.
(i) The format( ) function used with strings is very versatile and powerful function used for formatting strings.
(ii) The curly braces {} are used as placeholders or replacement fields which get replaced along with format( ) function.
Example:
num1 = int (input("Number 1:"))
num2 = int (input("Number 2:"))
print ("The, sum of {} and {} is {}". format (num1, num2, (num1 + num2)))
Output:
Number 1: 34
Number 2: 54
The sum of 34 and 54 is 88.
3.
Output:
Weool
4.
| Syntax | Description | Example |
| (a) capitalize() | Used to capitalize the first character of the string | >>> city="chennai" >>> print(city, capitalize( )) Chennai |
| (b) swapcase( ) | It will change case of every character to its opposite case vice-versa. | >>> strl="tAmilL NaDu" >>>print(strl.swapcase( )) TaMIl nAdU |
5.
Str 1 = "COMPUTER"
index = 0
for i in str 1:
print (str 1[:index -1])
index =1
6.
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.
7.
strl=' * '
i=1
while i< = 5:
print (strl*i)
i+=1
8.
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
9.
String Operators:
Python provides the following operators for string operations. These operators are useful to manipulate string.
(i) Concatenation (+):
Joining of two or more strings is called as Concatenation. The plus (+) operator is used to concatenate strings in python.
Example:
>>> "welcome" + "Python"
'welcome python'
(ii) Append (+ =):
Adding more strings at the end of an existing string is known as append. The operator += is used to append a new string with an existing string.
Example:
>>> str1 = "welcome to"
>>> str1 + = "Learn Python"
>>> print (str1)
Welcome to Learn Python
(iii) Repeating (*):
The multiplication operator (*) is used to display a string in multiple number of times.
Example:
>>> str1= "welcome "
>>> print (str1 *4)
Welcome Welcome Welcome Welcome
(iv) String slicing:
Slice is a substring of a main string.
A substring can be taken from the original string by using [ ] operator and index or subscript values. Thus [ ] is also known as slicing operator. Using slice operator, we have to slice one or more substrings from a main string.
General format of slice operation:
str[start:end]
Where start is the beginning index and end is the last index value of a character in the string. Python takes the end value less than one from the actual index specified.
Example: I
Slice a single character from a string
>>>str 1 = "THIRUKKURAL"
>>>print (str 1 [0])
T
(v) Stride when slicing string:
Example :
>>>str1 = "Welcome to learn python"
>>>print(str1[::-2])
Output :
nhy re teolW
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