Q. What will be the output produced by following code fragments?
(a)
y = str(123)
x = "hello" * 3
print (x , y)
x = "hello" + "world"
y = len(x)
print (y, x)
(b)
x = "hello" + \
"to Python" + \
"world"
for chr in x :
y = chr
print (y, ":", end = ' ')
(c)
x = "hello world"
print (x[:2], x[:-2], x[-2:])
print (x[6], x[2:4])
print (x[2:-3], x[-4:-2])
Answer =
(a)
Output: -
hellohellohello 123
10 helloworld
>>>
(b)
Output :-
h : e : l : l : o : t : o : : P : y : t : h : o : n : w : o : r : l : d :
(c)
Output: -
he hello wor ld
w ll
llo wo or
>>>
(b) is wrong
ReplyDeleteit would be
h : e : l : l : o : t : o : : P : y : t : h : o : n : w : o : r : l : d :
Right : )
Deletethere will be a blank space between to and Python b) h :e :l :l :o :t :o : :P :y :t :h :o :n :w :o :r :l :d :
Deleteall the answers are correct...
ReplyDeleteThank you : )
Deletethankyou so much sir.
ReplyDeleteOutput will be
ReplyDeleteA)
hellohellohello 123
10 helloworld
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )