You are on page 1of 4

UNIT - 3 STRING MANIPULATION

I. Choose the correct answer:


1. A _________ is a sequence of characters.
a. comment b. string c. new line d. index
2. String which contains double quotes should be defined within _________ quotes.
a. double b. no c. triple d. none of these
3. Strings in python are _____________.
a. mutable b. updateable c. changeable d. immutable
4. Defining strings within triple quotes also allows creation of ___________ strings.
a. single line b. comment line c. multiline d. mutable
5. In python, individual characters of a string can be accessed by using the method of __________.
a. grouping b. splitting c. indexing d. all of the above
6. Python allocates an ____________ value for each of its character.
a. index b. string c. decimal d. negative
7. The index values are otherwise called as ______________.
a. numbers b. string c. subscript d. alphabet
8. The ____________ can be positive or negative integer numbers.
a. index b. subscript c. both a & b d. none of these
9. Only ________ are allowed to be passed as index.
a. integer b. decimal c. negative number d. string
10. Float or other types will cause a __________ error.
a. index b. decimal c. type d. number
11. _________ command is used to remove the entire string variable.
a. remove() b. del c. delete d. erase
12. Strings in python can be formatted using _______________ function.
a. edit() b. change() c. format() d. mutable()
13. ____________ acts as placeholders in format() function.
a. { } b. ( ) c. [ ] d. “ “
14. _________ is used as formatting operator to construct strings.
a. & b. * c. % d. #
15. Operator used for concatenation in string is ___________.
a. + b. - c. * d. =
16. The __________ operator is used to append a string at the end of an existing string.
a. *= b. /= c. -= d. +=
17. Displaying a string for ‘n’ number of times is called ______________.
a. separating b. repeating c. duplicating d. copying
18. name=”Ajeesh”
print(name * 5)
How many times “Ajeesh” get printed.
a. 6 b. 7 c. 5 d. 1
19. __________ operator is used to slice a string in python.
a. () b. { } c. “ “ d. [ ]
20. A __________ can be obtained from the main string by using the [ ] operator and index values.
a. slice b. stride c. split d. cut
21. If we want to slice the first 6 character from a string, we have to write the statement as ___________.
a. name[6:0] b. name[0:6] c. name[0,6] d. name(0,6)
22. The default value of stride is ____________.
a. 1 b. 2 c. 0 d. 7
23. The _______ function removes whitespaces from the beginning and the end of the string.
a. strip() b. remove() c. del() d. clear()
24. The ___________ function returns string in lower case.
a. lower() b. small() c. upper() d. tolower()
25. The _________ function splits the given string into substrings if it finds the instances of the separator.
a. cut() b. split() c. strip() d. spell()
26. __________ function performs string slicing.
a. split() b. cut() c. strip() d. spell()
27. The ____________ function converts the first character of the string to uppercase.
a. startupper() b. firstupper() c. capitalize() d. 1upper()
28. To check if a certain phrase or a character occurs in a string, we can use ___________ operator.
a. member b. membership c. non membership d. ship
29. ___________ function is used to check whether the string contains only alphabets.
a. isalnum() b. isalphabet() c. isalpha() d. isdigit()
30. ___________ function is used to check whether the string contains only numbers.
a. isalnum() b. isnumber() c. isalpha() d. isdigit()
II. Fill in the blanks:
1. _____________ may be a combination of letters, numbers or special characters enclosed within single,
double or even triple quotes. [String]
2. String in _________ quotes cannot hold any other single quoted character in it because the compiler will not
recognize where to start and the string. [single]
3. The positive index value for the first character will be ___________. [ 0]
4. The index for the last character will be ____________. [n-1]
5. The negative indexing starts from ___________. [-1]
6. ___________ error will occur while accessing an index out of range. [Index]
7. ______________ function is used to change all the occurrence of a particular character in a string while
printing it. [replace()]
8. Python does not allow to __________ a particular character from a string. [delete]
9. ___________ is a powerful tool for formatting strings. [format()]
10. ‘format()’ function uses ________ as placeholders which can hold arguments. *curly braces , -+
11. Formatting characters are replaceable parts of the strings that are _____________ with the data stored in
variables in a print() function. [replaced]
12. Joining one or more strings together is called ______________. [concatenation]
13. Adding a string at the end of an existing string is called _____________. [appending]
14. The __________ operator is used to display the same string for the specified number of times. [*]
15. __________ is a part of the main string. [Slice]
16. Stride value is ____________. [optional]always takes ‘end index value -1 as the __________ value. [end]
17. Python has a set of built-in string function that can be used to ____________ string. [manipulate]
18. The ______________ function returns ‘true’ if the entire string is in lowercase, otherwise returns ‘false’.
[islower()]
19. The __________ function returns the entire string in upper case. [upper()]
20. The ___________ function returns ‘True’ if the entire string is in uppercase, otherwise returns ‘false’.
[isupper()]
21. The _____________ function returns ‘true’ if the character is a blank space, otherwise returns ‘false’.
[isspace()]
22. _______ function is used to check whether a string contains only letters and digits. [isalnum()]
23. The ___________ function will change the case of every character in the string to its opposite case.
[swapcase()]
24. The ___________ function returns the string in title case. [title()]
25. The ___________ function returns the number of occurrence of the substring within the given string or
range. [count()]
III. Match the following: Answer
1. Index value - a. in or not in 1- e
2. Strings - b. 1 2- f
3. Floating point numbers - c. [ ] 3- j
4. Octal integer - d. + 4- h

5. Appending - e. 0 5- i

6. Repeating - f. %s 6- g
7- b
7. Stride default value - g. *
8- d
8. Concatenation - h. %o
9- c
9. Slicing operator - i. +=
10 - a
10. Check string - j. %f
IV. Say true or false:
1. Strings in python are mutable. [False]
2. Subscript value is also called as index value. [True]
3. The index values can be negative numbers. [True]
4. Any type of numbers can be used as index value. [False]
5. del command is used to delete a particular character from string. [False]
6. Curly braces { } are used as placeholders in format() function. [True]
7. ‘+’ operator is used to append a string at the end of an existing string. *False+
8. Displaying a string for ‘n’ number of times is called repeating. *True+
9. Slice is a part of main string. [True]
10. The tile() function returns the string in uppercase. [False]

You might also like