CAMPUSAPTITUDEPYTHON
CAMPUSAPTITUDEPYTHON
Max Marks: 30
Time: 45 Mins
1. Which is the correct operator for power(xy)?
a) X^y
b) X**y
c) X^^y
d) None of the mentioned
5. Given a function that does not return any value, What value is thrown by
default when executed in shell.
a) int
b) bool
c) void
d) None
6. Following set of commands are executed in shell, what will be the output?
>>>str="hello"
>>>str[:2]
a)he
b)lo
c)olleh
d) hello
def example(a):
a = a + '2'
a = a*2
return a
>>>example("hello")
a)indentation Error
b)cannot perform mathematical operation on strings
c)hello2
d) hello2hello2
Quest Innovative Solutions Pvt. Ltd.
Head Office : MKS Towers, SA Road, Kadavanthra, Cochin - 20, Kerala, India.Ph:+91-484-2204108/09 | www.qis.co.in | Email: [email protected]
ISO 9001:2015 & 10002:2014 Certified Company
COCHIN | TRIVANDRUM | CALICUT | KANNUR
QPYTHON-103
>>>"a"+"bc"
a)a
b)bc
c)bca
d) abc
>>>print r"\nhello"
The output is
a)a new line and hello
b)\nhello
c)the letter r and then hello
d) error
14. Which of the following is not the correct syntax for creating a set?
a)set([[1,2],[3,4]])
b)set([1,2,2,3,4])
c)set((1,2,3,4))
d) {1,2,3,4}
16. Which of the following function of dictionary gets all the keys from the
dictionary?
a) getkeys()
b) key()
c) keys()
print n[2]
a) [6, 5, 4]
b) 2
c) 7
d) [3, 2, 1]
a)Interpreter
b)Compiler
c)Both
a)Instagram
b)Pinterest
c)NASA's website
d)All
a)Java
b)Python
a) Module
b) Library
c) Object
d) function
print 'hello'[::-1]
a)olleh
b)hello -1
c)o
d)Error
a) print(t[3])
b) t[3] = 45
c) print(max(t))
d) print(len(t))
>>>t = (1, 2, 4, 3, 8, 9)
>>>[t[i] for i in range(0, len(t), 2)]
a)[2,3,9].
b)[1,2,4,3,8,9].
c)[1,4,8].
d) (1, 4, 8)
d = {"john":40, "peter":45}
"john" in d
a) True
b) False
c) None
d) Error
d = {"john":40, "peter":45}
print(list(d.keys()))
a)[“john”, “peter”].
b) [“john”:40, “peter”:45].
c) (“john”, “peter”)
d) (“john”:40, “peter”:45)
>>>print(names[-1][-1])
a) A
b) Daman
c) Error
d) n