WorksheetsStrings in python -1
Total questions: 22
Worksheet time: 13mins
word = "amazing"
For the given string if we run word[2:5] what does it mean?
It will extract alphabets from index 2 to index 4
It will extract alphabets from index 2 to index 5
It will extract alphabets from position 2 to position 4
It will extract alphabets from position 2 to position 5
Which method is used to convert a given string in Capital letters?
Capital
Upper
ConverttoUpper
Capitalize
Which of the following is not a valid string function?
isalphanumeric
isspace
islower
isalnum
string="HELlo"
What will be the result of string.isupper()?
(a)
s1="Hello"
n1=10
print(s1+n1)
What is the error in this code?
Print statement not written in quotes
Numeric value not written in quotes
colon not written after the print statement
string cannot be added to a number
In Python, strings are…
char arrays
changeable
immutable
str objects
Which of the following mathematical operators can be used to concatenate strings:
*
/
-
+
what is a string?
any numeric value
any float value
any character value
any special symbol value
str1='101'
x=int(str1)
z=x+400
print(z)
101400
x400
501
none of above
fruit1="kiwi"
fruit2="strawberry"
print(len(fruit1))
print(len(fruit2))
kiwi and strawberry
4
10
4 10
410
index of a string begins with
1
0
a
-1
slicing string X="BOnVoyage"
print X[0:5]
BOnVoy
BOnVo
oyage
bonvo
a="god help those who help themselves"
"help" in "a"
true
false
wrong out put
error
cheer = "Go Eagles!"
print cheer[1:4]
cheer = "Go Eagles!"
print cheer[0:1]
cheer = "Go Eagles!"
print cheer[5:8]
cheer = "Go Eagles!"
print cheer[7:]
cheer = "Go Eagles!"
print cheer[:5]
cheer = "Go Eagles!"
print cheer[ ]
If the output is Eagle
cheer = "Go Eagles!"
print (cheer[ ] + cheer [ ] + cheer [ ])
If the output is Goggles
"AB-CD-EF".partition('-') , the function returns the output
('ABCD','-','EF')
('AB', '-', 'CDEF')
('AB', '-', 'CD-EF')
None of the above
Give the output of the following statements
>>> str='Hello World'
>>>str.istiltle()
TRUE
FALSE
