0% found this document useful (0 votes)
59 views

Chapter-10 Assignment

The document contains 15 questions about string manipulation in Python. It asks the user to write programs that can reverse a string, count and display vowels, reverse words, prove that a string is a tuple, explain string slicing, and more. It also provides code snippets and asks for the expected output. The questions cover basic string operations like length, indexing, slicing, formatting, counting characters, checking palindromes, capitalization and more.

Uploaded by

sainothegamer
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views

Chapter-10 Assignment

The document contains 15 questions about string manipulation in Python. It asks the user to write programs that can reverse a string, count and display vowels, reverse words, prove that a string is a tuple, explain string slicing, and more. It also provides code snippets and asks for the expected output. The questions cover basic string operations like length, indexing, slicing, formatting, counting characters, checking palindromes, capitalization and more.

Uploaded by

sainothegamer
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

CHAPTER-10 ASSIGNMENT

STRING MANIPULATION
Q1. Write a program to read a string and display it in reverse order.
Q2. Write a program in python to count and display vowels in a string.
Q3. Write a program in python to reverse words in a given String in Python.
Q4. Python treats a string as special kind of tuple, if yes, prove it.
Q5. What is a string slice? How is it useful?
Q6. What is the output of the following Python program section?
A. st='Computer Science'
x=st.lower()
y=x.replace('computer','Computer')
print(y)

B. txt='computer science and informatics practices'


words=txt.split(' ')
l=len(words)
print (l)

C. st=['C','o','m','p','u','t','e','r']
w=''.join(st)
print(w)

D. my_string = "python"
for i in range(my_string):
print(i)

E. my_string = 'python'
for i in range(len(my_string)):
my_string[i].upper()
print (my_string)

F. word = ‘aeioubcd’
print (word [:3] + word [3:])

G. print("xyz DEF".capitalize())

H. print("ayybcyzxcxyy".count('yy'))

I. print("Hello {0} and {1}".format('python', 'java'))

J. print('while'.isidentifier())

K. print('5.1'.isnumeric())
Page 1 of 2
Q7. Write a Python program to calculate the length of a string.
Q8. Write a Python program to count the character frequency in a string.
Q9. Write a Python program to change a given string to a new string where the first and last
characters have been exchanged.
Q10. Write a Python script that takes input from the user and displays that input back in upper and
lower cases.
Q11. Write a Python program to lowercase first n characters in a string.
Q12. Write a Python program to Check Whether a String is Palindrome or Not.
Q13. Write a program that asks the user to enter a string. The program should then print the
following:
a. The total number of characters in the string
b. The string repeated 10 times
c. The first character of the string
d. The first three characters of the string
e. The last three characters of the string
f. The string backwards
g. The string with its first and last characters removed
h. The string in all caps
i. The string with every a replaced with an e

Q14. Write a program that asks the user to enter their name in lowercase and then capitalizes the
first letter of each word of their name.
Q15. Write a program that asks the user to enter a string, then prints out each letter of the string
doubled and on a separate line.

Page 2 of 2

You might also like