NEW
Font size
WorksheetsSTRING HANDLING IN PYTHON
Total questions: 24
Worksheet time: 14mins
One of the following functions is not used with Python String
Split
Remove
Replace
Choose the correct syntax of the split function:
x.split[]
split(x)
x.split(",", 3)
X.SPLIT(",", 3)
The correct syntax of the len function for string x:
x.len()
len[x]
LEN[]
len(x)
The correct syntax for converting the string x to uppercase is :
X.upper()
upper(x)
x.UPPER[ ]
x.upper()
To remove the spaces present at start and end of the string, you can use
split()
len()
strip()
remove()
Let x= "Python", the output of print(x.upper()) is
python
PYTHON
_PYTHON
"PYTHON"
For string symbol + means........................
addition
swapp
concatenation
multiplication
index of a string begins with
1
0
a
-1
slicing string X="BOnVoyage"
print X[0:5]
BOnVoy
BOnVo
oyage
bonvo
Slicing string
x="BOnvoyage
print(x[4: ])
BOnvo
bonvo
voyage
VOYAGE
Returning a range of characters (part of a string) is done using which syntax?
Slice
Splice
Cut
Select
Python accepts single ('), double (") and triple (''' or """) quotes to denote strings. Which of the following is NOT acceptable Python syntax?
print('Hello World')
print("Hello World")
print('Hello World")
print(""'Hello World'"")
What is printed by the following statement?
print("P" not in "APCSP")
True
False
Error
What is printed by the following statement?
print("A" in "APCSP")
True
False
Error
Evaluate the following expression:
"dog" < "Dog"
They are the same word
True
False
Which operator returns True if target string is somewhere in the search string; otherwise it returns False.
==
!=
in
is
What syntax can you use to insert a line break between strings so that they appear over multiple lines?
\l
/
\\n
\n
True or False: Python automatically adds spaces when we add Strings together.
True
False
True or False: Subtracting Strings removes the letters of one from the other.
True
False
