0% found this document useful (0 votes)
20 views2 pages

CP Stringv Rfeport

The document outlines a series of Python programming tasks related to string manipulation. It includes searching for a character in a string, counting vowels and consonants, determining string length, reversing a string, checking for palindromes, and combining multiple strings. Each task is accompanied by sample code snippets to demonstrate the functionality.

Uploaded by

fahimmuntasir972
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views2 pages

CP Stringv Rfeport

The document outlines a series of Python programming tasks related to string manipulation. It includes searching for a character in a string, counting vowels and consonants, determining string length, reversing a string, checking for palindromes, and combining multiple strings. Each task is accompanied by sample code snippets to demonstrate the functionality.

Uploaded by

fahimmuntasir972
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

#1.

Search a character in a string


#4. Count vowels, consonants, digits, spaces, special
s = input("Enter string: ") characters
ch = input("Enter character: ")
s = input("Enter string: ")
if ch in s:
v = c = d = sp = sc = 0
print("Found at index:", [Link](ch))
for ch in s:
else:
if [Link]() in 'aeiou':
print("Not found")
v += 1
elif [Link]():
#2. Frequency of a character
c += 1
s = input("Enter string: ")
elif [Link]():
ch = input("Enter character: ")
d += 1
count = [Link](ch)
elif [Link]():
print("Frequency:", count)
sp += 1
else:
#3. Count capital & small letters
sc += 1
s = input("Enter string: ")
print("Vowels:", v)
upper = 0
print("Consonants:", c)
lower = 0
print("Digits:", d)
for c in s:
print("Spaces:", sp)
if [Link]():
print("Special chars:", sc)
upper += 1
elif [Link]():
count += 1
lower += 1
print("Alphanumeric characters:", count)
print("Uppercase:", upper)
print("Lowercase:", lower)
#5. Count alphanumeric characters #9. Reverse a string
s = input("Enter string: ") s = input("Enter string: ")
count = 0 rev = s[::-1]
for ch in s: print("Reversed string:", rev)
if [Link]():
count += 1 #10. Check palindrome
print("Alphanumeric characters:", count) s = input("Enter string: ")

if s == s[::-1]:
#6. Length of a string print("Palindrome")
s = input("Enter string: ") else:
print("Length:", len(s)) print("Not Palindrome")

#7. Add three strings


s1 = input("Enter first string: ")
s2 = input("Enter second string: ")
s3 = input("Enter third string: ")

result = s1 + s2 + s3
print("Combined string:", result)

#8. Copy a string


s1 = input("Enter string: ")
s2 = s1

print("Copied string:", s2)

#9. Reverse a string


s = input("Enter string: ")
rev = s[::-1]

You might also like