1
CHAPTER: STRING IN PYTHON
ASSIGNMENT SET – 1
Time: 30 min M.M. – 20
Instructions:
 All Questions are compulsory
 Q1 to Q6 carry 1 mark
 Q7 to Q10 carry 2 marks
 Q11 to Q12 carry 3 marks
Q1. Write the code to create an empty string named “str”.
Q2. Name the function which count the total number of characters in a
string.
Q3. Fill the index value in place of ‘?’ so that the output should come ‘o’
str = “csiplearninghub.com”
print(str[?])
Q4. Write the function which removes the spaces from the left side of
the string.
Q5. What type of error is returned by the following statement?
str = “csiplearninghub.com”
str[7] = ‘e’
Q6. What do you mean by concatenation of string?
2
Q7. Write a program to accept a string and display in reverse.
Q8. Write a function count( ) in python which takes string as argument
and return total number of words.
Q9. Write the output of the following:
a. print(“Suman” > “Sumati”)
b. print(“amit”.isalpha())
Q10. Write the output of the following code :
str = "CSIPLearningHuB"
newstr = " "
for i in range(len(str)):
if str[i].isupper():
newstr =newstr + str[i].lower()
if str[i].islower():
newstr =newstr + str[i].upper()
print(newstr)
Q11. Write a program in python that accept a string from the user and
display the following:
1. Total number of vowels
2. Total number of digits
3. Total number of words.
3
Q12. Write the output of the following:
str = "CSIPLearningHuB"
print(str[::-1])
print(str[-7:-1:2])
print(str[3:14:3])

CBSE Python String Assignment

  • 1.
    1 CHAPTER: STRING INPYTHON ASSIGNMENT SET – 1 Time: 30 min M.M. – 20 Instructions:  All Questions are compulsory  Q1 to Q6 carry 1 mark  Q7 to Q10 carry 2 marks  Q11 to Q12 carry 3 marks Q1. Write the code to create an empty string named “str”. Q2. Name the function which count the total number of characters in a string. Q3. Fill the index value in place of ‘?’ so that the output should come ‘o’ str = “csiplearninghub.com” print(str[?]) Q4. Write the function which removes the spaces from the left side of the string. Q5. What type of error is returned by the following statement? str = “csiplearninghub.com” str[7] = ‘e’ Q6. What do you mean by concatenation of string?
  • 2.
    2 Q7. Write aprogram to accept a string and display in reverse. Q8. Write a function count( ) in python which takes string as argument and return total number of words. Q9. Write the output of the following: a. print(“Suman” > “Sumati”) b. print(“amit”.isalpha()) Q10. Write the output of the following code : str = "CSIPLearningHuB" newstr = " " for i in range(len(str)): if str[i].isupper(): newstr =newstr + str[i].lower() if str[i].islower(): newstr =newstr + str[i].upper() print(newstr) Q11. Write a program in python that accept a string from the user and display the following: 1. Total number of vowels 2. Total number of digits 3. Total number of words.
  • 3.
    3 Q12. Write theoutput of the following: str = "CSIPLearningHuB" print(str[::-1]) print(str[-7:-1:2]) print(str[3:14:3])