Font size
WorksheetsAssessment #2
Total questions: 20
Worksheet time: 20mins
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'"")
For strings, the + operator represents
Concatenation
Addition
Appending
Recantation
data = "No Way!" The expression len(data) evaluates to:
7
9
8
6
What syntax can you use to insert a line break between strings so that they appear over multiple lines?
\l
/
\\n
\n
Which is the most appropriate data type for: "13th December"
Float
Boolean
Integer
String
What will the output be from the following code?
print("Hello world!" * 2)
TypeError
Hello world world!
Hello world!Hello world!
Hello world! * 2
What will the output be from the following code?
print("3+4")
7
34
3+4
SyntaxError
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)
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
slicing string X="BOnVoyage"
print X[0:5]
BOnVoy
BOnVo
oyage
bonvo
