Home | 12 ஆம் வகுப்பு | 12வது கணினி அறிவியல் | சரங்களை பயன்படுத்தி நிரல்

பைத்தான் - சரங்களை பயன்படுத்தி நிரல் | 12th Computer Science : Chapter 8 : Core Python : Strings and String Manipulation

   Posted On :  22.08.2022 07:47 pm

12 வது கணினி அறிவியல் : அலகு 8 : Core பைத்தான் : சரங்கள் மற்றும் சரங்களை கையாளுதல்

சரங்களை பயன்படுத்தி நிரல்

பைத்தான் அறிமுகம் : சரங்கள் மற்றும் சரங்களை கையாளுதல் : சரங்களை பயன்படுத்தி நிரல்

சரங்களை பயன்படுத்தி நிரல்


எடுத்துக்காட்டு 8.4: கொடுக்கப்பட்ட சரம் பாலின்ட்ரோமா இல்லையா என்பதை சோதிக்கும் நிரல்

strl = input ("Enter a string:")

str2 =''

index=-1

for i in strl:

str2 += str1[index]

index -= 1

print ("The given string = {} \n The Reversed string = {}".format(str1, str2))

if (strl==str2):

print ("Hence, the given string is Palindrome")

else:

print ("Hence, the given is not a palindrome")

வெளியீடு :1

Enter a string: malayalam

The given string = malayalam

The Reversed string = malayalam

Hence, the given string is Palindrome

வெளியீடு : 2

Enter a string: welcome

The given string = welcome

The Reversed string = emoclew

Hence, the given string is not a palindrome

 

எடுத்துக்காட்டு 8.5: பின்வரும் வடிவத்தை அச்சிடும் நிரல்

*

* *

* * *

* * * *

* * * * *

strl=' * '  

i=1

while i<=5:

print (str1*i)

i+=1

வெளியீடு

*

* *

* * *

* * * *

* * * * *


எடுத்துக்காட்டு 8.6: கொடுக்கப்பட சரத்தில் உள்ள உயிர் எழுத்துக்கள் மற்றும் மெய் எழுத்துக்களின் எண்ணிக்கையை கண்டறியும் நிரல்

strl = 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))

வெளியீடு

Enter a string: Tamilnadu School Education

The given string contains 11 vowels and 15 consonants


எடுத்துக்காட்டு 8.7: ஏபோரியன் தொடரை உருவாக்கும் நிரல் (ஏபோரியன் தொடர் அகர வரிசைப்படி பட்டியலை உருவாக்கும்)

strl="ABCDEFGH"

str2="ate"

for i in strl:

print ((i+str2),end='\t')

வெளியீடு

Aate

Bate

Cate

Date

Eate

Fate

Gate

Hate


எடுத்துக்காட்டு 8.8: பயனரிடமிருந்து பெறப்படும் சரத்தில் உள்ள உயிர் எழுத்துக்களை நீக்கிவிட்டு அதே சரத்தை வெளிப்படுத்தும் நிரல்

def rem_vowels(s):

temp_str="

for i in s:

if i in "aAeEiloOuU":

pass

else:

temp_str+=i

print ("The string without vowels: '', temp_str)

strl = input ("Enter a String: ")

rem_vowels (str1)

வெளியீடு

Enter a String: Mathematical fundations of Computer Science

The string without vowels: Mthmtcl fndtns f Cmptr Scnc


எடுத்துக்காட்டு 8.9: கொடுக்கப்பட்ட சரத்தில் ஒரு குறிப்பிட்ட குறியுரு எத்தனை முறை இடம் பெறுகிறது என்பதை கணக்கிடும் நிரல்.

def count(s, c):

c1=0

for i in s:

if i == c:

cl+=1

return cl

strl=input ("Enter a String: ")

ch=input ("Enter a character to be searched: ")

cnt=count (strl, ch)

print ("The given character {} is occurs {} times in the given string".format(ch,cnt))

வெளியீடு

Enter a String: Software Engineering

Enter a character to be searched: e

The given character e is occurs 3 times in the given string

Tags : Python பைத்தான்.
12th Computer Science : Chapter 8 : Core Python : Strings and String Manipulation : Programs using Strings Python in Tamil : 12th Standard TN Tamil Medium School Samacheer Book Back Questions and answers, Important Question with Answer. 12 வது கணினி அறிவியல் : அலகு 8 : Core பைத்தான் : சரங்கள் மற்றும் சரங்களை கையாளுதல் : சரங்களை பயன்படுத்தி நிரல் - பைத்தான் : 12 ஆம் வகுப்பு தமிழ்நாடு பள்ளி சமசீர் புத்தகம் கேள்விகள் மற்றும் பதில்கள்.
12 வது கணினி அறிவியல் : அலகு 8 : Core பைத்தான் : சரங்கள் மற்றும் சரங்களை கையாளுதல்