Q. What is the result of the following expressions?


(a)

print ("""

1

    2

        3

""")


(b)

text = "Test. \nNext line."

print (text)


(c)

print ('One', 'Two' * 2)

print ('One' + 'Two' * 2)

print (len('0123456789'))


(d)

s = '0123456789'

print (s[3], s[0:3], '-', s [2:5])

print (s[:3], '-', s[3:], ',', s[3:100])

print (s[20:], s[2:1], s[1:1])


(e)

s = '987654321'

print (s[-1], s[-3])

print (s[-3:], s[:-3])

print (s[-100:-3], s[-100:3])



Answer =

(a)

Output: -

1
    2
        3
>>>

(b)

Output: -

Test.
Next line.
>>>

(c)

Output: -

One TwoTwo
OneTwoTwo
10
>>>

(d)

Output: -

3 012 - 234
012 - 3456789 , 3456789
>>>

(e)

Output: -

1 3
321 987654
987654 987
>>>

4 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post