Computer Science
Which of the following is not a Python legal string operation?
(a) 'abc' + 'abc'
(b) 'abc' * 3
(c) 'abc' + .3
(d) 'abc.lower()
Python String Manipulation
29 Likes
Answer
'abc' + .3 is not a legal string operation in Python. The operands of + operator should be both string or both numeric. Here one operand is string and other is numeric. This is not allowed in Python.
Answered By
10 Likes
Related Questions
Out of the following operators, which ones can be used with strings in Python?
=, -, *, /, //, %, >, <>, in, not in, <=
What is the result of following statement, if the input is 'Fun'?
print(input("…") + "trial" + "Ooty" * 3)
Can you say strings are character lists? Why? Why not?
Given a string S = "CARPE DIEM". If n is length/2 (length is the length of the given string), then what would following return?
(a) S[: n]
(b) S[n :]
(c) S[n : n]
(d) S[1 : n]
(e) S[n : length - 1]