The format function, when applied on a string returns ___________
Anonymous Quiz
28%
Error
9%
imt
10%
bool
53%
str
What will be the output of the βhelloβ +1+2+3?
Anonymous Quiz
39%
hello123
8%
hello
39%
Error
14%
hello6
What will be displayed by print(ord(βbβ) β ord(βaβ))?
Anonymous Quiz
18%
0
57%
1
22%
-1
3%
2
π5β€1
Say s=βhelloβ what will be the return value of type(s)?
Anonymous Quiz
4%
int
9%
bool
59%
str
28%
String
π4
To retrieve the character at index 3 from string s=βHelloβ what command do we execute (multiple answers allowed)?
Anonymous Quiz
18%
s[]
36%
s.getitem(3)
26%
s.__getitem__(3)
20%
s.getItem(3)
β€1
To return the length of string s what command do we execute?
Anonymous Quiz
44%
len(s) OR s.__len__()
43%
len(s) only
7%
size(s)
7%
s.size()
π1
Explanation:
len(s) is a built-in function in Python to get the length of the string s, whereas s.len() calls the len method of the string object s. Itβs less common but functionally equivalent to len(s). So, we can use either of these.
len(s) is a built-in function in Python to get the length of the string s, whereas s.len() calls the len method of the string object s. Itβs less common but functionally equivalent to len(s). So, we can use either of these.
To check whether string s1 contains another string s2, use ________
Anonymous Quiz
30%
s1.__contains__(s2)
32%
s2 in s1
32%
s1.contains(s2)
6%
si.in(s2)
π4
What will be the output of the following Python code?
print("abc DEF".capitalize())
print("abc DEF".capitalize())
Anonymous Quiz
7%
abc def
59%
ABC DEF
20%
Abc def
14%
Abc Def
What will be the output of the following Python code?
print("abc. DEF".capitalize())
print("abc. DEF".capitalize())
Anonymous Quiz
7%
abc. def
38%
ABC. DEF
32%
Abc. def
22%
Abc. Def
π€―2
What will be the output of the following Python code?
print("abcdef".center())
print("abcdef".center())
Anonymous Quiz
43%
cd
23%
abcde
24%
error
9%
none
β€3π1
What will be the output of the following Python code?
print("abcdef".center(0))
print("abcdef".center(0))
Anonymous Quiz
27%
cd
26%
abcdef
34%
error
12%
None
What will be the output of the following Python code?
print('*', "abcdef".center(7), '*')
print('*', "abcdef".center(7), '*')
Anonymous Quiz
37%
* abcdef *
46%
*abcdef *
17%
* abcdef*
What will be the output of the following Python code?
print('*', "abcdef".center(7), '*', sep='')
print('*', "abcdef".center(7), '*', sep='')
Anonymous Quiz
32%
* abcdef *
35%
* abcdef *
21%
*abcdef *
12%
* abcdef*
β€1
What will be the output of the following Python code?
print("abcdef".center(7, 1))
print("abcdef".center(7, 1))
Anonymous Quiz
23%
1abcdef
40%
abcdef1
12%
abcdef
25%
error
π2
What will be the output of the following Python code?
print("abcdef".center(7, '1'))
print("abcdef".center(7, '1'))
Anonymous Quiz
18%
1abcdef
43%
abcdef1
8%
abcdef
31%
error
π2
What will be the output of the following Python code?
print("abcdef".center(10, '12'))
print("abcdef".center(10, '12'))
Anonymous Quiz
43%
12abcdef12
21%
abcdef1212
12%
1212abcdef
23%
error
π€―2
What will be the output of the following Python code?
print("xyyzxyzxzxyy".count('yy'))
print("xyyzxyzxzxyy".count('yy'))
Anonymous Quiz
62%
2
8%
0
25%
error
5%
none
π3
What will be the output of the following Python code?
print("xyyzxyzxzxyy".count('yy', 1))
print("xyyzxyzxzxyy".count('yy', 1))
Anonymous Quiz
42%
2
15%
0
33%
1
11%
none
What will be the output of the following Python code?
print("xyyzxyzxzxyy".count('yy', 2))
print("xyyzxyzxzxyy".count('yy', 2))
Anonymous Quiz
44%
2
14%
0
32%
1
10%
none
π1π€1