Worksheetspython strings
Total questions: 20
Worksheet time: 11mins
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("Hello world!\nHello world!")
Hello world! Hello world!
Hello world!
Hello world!
SyntaxError
Hello world!
What will the output be from the following code?
print("3+4")
7
34
3+4
SyntaxError
What will the output be from the following code?
print("Hello world!")
SyntaxError
Hello world!
"Hello world!"
print(Hello world!)
Which is the powerful function used for formatting strings?
chr( )
format( )
title( )
capitalize( )
Which of the following will give "Simon" as output?
If str1="John,Simon,Aryan"
print(str1[-7:-12])
print(str1[-11:-7])
print(str1[-11:-6])
print(str1[-7:-11])
Say s=”hello” what will be the return value of type(s)?
STRING
bool
str
String
What will be the output of the following Python code?
print("D", end = ' ')
print("C", end = ' ')
print("B", end = ' ')
print("A", end = ' ')
DCBA
A,B,C,D
D C B A
D
C
B
A
What will be the output of the “hello” +1+2+3?
hello123
hello
Error
hello6
word = "amazing"
For the given string if we run word[2:5] , what would the result be?
mazi
mazin
azi
azin
For strings, the + operator represents
Concatenation
Addition
Appending
Recantation
Which is the most appropriate data type for: "13th December"
Float
Boolean
Integer
String
Print("Hello world!")
print("Hello" + "world" + "today")
What is the output from this code?
ell
llo
ello,
Hello
If s='Sammy' what is the output of s[2:]
'Sa'
'Sam'
'mmy'
'ammy'
