Python Questions and Answers – Strings – 5
This set of Basic Python Questions & Answers focuses on “Strings”.
1. What is the output of the following?
a) abc def
b) ABC DEF
c) Abc def
d) Abc Def
View Answer
b) ABC DEF
c) Abc def
d) Abc Def
View Answer
2. What is the output of the following?
a) abc def
b) ABC DEF
c) Abc def
d) Abc Def
View Answer
b) ABC DEF
c) Abc def
d) Abc Def
View Answer
3. What is the output of the following?
a) cd
b) abcdef
c) error
d) none of the mentioned
View Answer
b) abcdef
c) error
d) none of the mentioned
View Answer
4. What is the output of the following?
advertisements
b) abcdef
c) error
d) none of the mentioned
View Answer
5. What is the output of the following?
a) * abcdef *
b) * abcdef *
c) *abcdef *
d) * abcdef*
View Answer
b) * abcdef *
c) *abcdef *
d) * abcdef*
View Answer
6. What is the output of the following?
a) * abcdef *
b) * abcdef *
c) *abcdef *
d) * abcdef*
View Answer
b) * abcdef *
c) *abcdef *
d) * abcdef*
View Answer
7. What is the output of the following?
a) * abcde *
b) * abcde *
c) *abcde *
d) * abcde*
View Answer
b) * abcde *
c) *abcde *
d) * abcde*
View Answer
Answer: c
Explanation: Padding is done towards the right-hand-side first when the final string is of even length.
Explanation: Padding is done towards the right-hand-side first when the final string is of even length.
advertisements
a) 1abcdef
b) abcdef1
c) abcdef
d) error
View Answer
b) abcdef1
c) abcdef
d) error
View Answer
Answer: d
Explanation: TypeError, the fill character must be a character, not an int.
Explanation: TypeError, the fill character must be a character, not an int.
9. What is the output of the following?
a) 1abcdef
b) abcdef1
c) abcdef
d) error
View Answer
b) abcdef1
c) abcdef
d) error
View Answer
Answer: a
Explanation: The character ‘1’ is used for padding instead of a space.
Explanation: The character ‘1’ is used for padding instead of a space.
10. What is the output of the following?
a) 12abcdef12
b) abcdef1212
c) 1212abcdef
d) error
View Answer
b) abcdef1212
c) 1212abcdef
d) error
View Answer
Answer: d
Explanation: The fill character must be exactly one character long
Explanation: The fill character must be exactly one character long
No comments:
Post a Comment