A directory of Objective Type Questions covering all the Computer Science subjects. Here you can access and discuss Multiple choice questions and answers for various compitative exams and interviews.

1. What is the output when following statement is executed ?
>>>"a"+"bc"
a. a
b. bc
c. bca
d. abc
View Answer Report Discuss Too Difficult!
Answer: (d).abc

2. What is the output when following statement is executed ?
>>>"abcd"[2:]
a. a
b. ab
c. cd
d. dc
View Answer Report Discuss Too Difficult!
Answer: (c).cd

3. The output of executing string.ascii_letters can also be achieved by:
a. string.ascii_lowercase_string.digits
b. string.ascii_lowercase+string.ascii_upercase
c. string.letters
d. string.lowercase_string.upercase
View Answer Report Discuss Too Difficult!
Answer: (b).string.ascii_lowercase+string.ascii_upercase

4. What is the output when following code is executed ?
>>> str1 = 'hello'
>>> str2 = ','
>>> str3 = 'world'
>>> str1[-1:]
a. olleh
b. hello
c. h
d. o
View Answer Report Discuss Too Difficult!
Answer: (d).o

5. What arithmetic operators cannot be used with strings ?
a. +
b. *
c.
d. All of the mentioned
View Answer Report Discuss Too Difficult!
Answer: (c).

6. What is the output when following code is executed ?
>>>print r"\nhello"
a. a new line and hello
b. \nhello
c. the letter r and then hello
d. error
View Answer Report Discuss Too Difficult!
Answer: (b).\nhello

7. What is the output when following statement is executed ?
>>>print('new' 'line')
a. Error
b. Output equivalent to print ‘new\nline’
c. newline
d. new line
View Answer Report Discuss Too Difficult!
Answer: (c).newline

8. What is the output when following statement is executed ?
>>> print(‘x\97\x98’)
a. Error
b. 97
98
c. x\97
d. \x97\x98
View Answer Report Discuss Too Difficult!
Answer: (c).x\97

9. What is the output when following code is executed ?
>>>str1="helloworld"
>>>str1[::-1]
a. dlrowolleh
b. hello
c. world
d. helloworld
View Answer Report Discuss Too Difficult!
Answer: (a).dlrowolleh

10. print(0xA + 0xB + 0xC) :
a. 0xA0xB0xC
b. Error
c. 0x22
d. 33
View Answer Report Discuss Too Difficult!
Answer: (d).33

Page 1 of 13