0% found this document useful (0 votes)
24 views

CAMPUSAPTITUDEPYTHON

This document contains 30 multiple choice questions about Python programming concepts like operators, data types, functions, strings, lists, dictionaries, tuples, and more. The questions test fundamental Python knowledge and range from basic syntax to more advanced topics.

Uploaded by

ROHITH
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views

CAMPUSAPTITUDEPYTHON

This document contains 30 multiple choice questions about Python programming concepts like operators, data types, functions, strings, lists, dictionaries, tuples, and more. The questions test fundamental Python knowledge and range from basic syntax to more advanced topics.

Uploaded by

ROHITH
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

QPYTHON-103

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

2. Which one of these is floor division?


a) /
b) //
c) %
d) None of the mentioned

3. Operators with the same precedence are evaluated in which manner?


a) Left to Right
b) Right to Left
c) Can’t say
d) None of the mentioned

4. Which of the following is an invalid variable?


a) my_string_1
b) 1st_string
c) foo
d) _

5. Given a function that does not return any value, What value is thrown by
default when executed in shell.
a) int
b) bool

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

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

7.What error occurs when you execute?


apple=mango
a)SyntaxError
b)NameError
c)ValueError
d) TypeError

8. Carefully observe the code and give the answer.

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

9.What data type is the object below ?


K=[1,23,‘hello’,1].
a)list
b)dictionary
c)array
d) tuple

10.Which of the following results in a SyntaxError ?


a)‘”Once upon a time…”,she said.’
b)“He said,‘Yes!'”
c)‘3\’
d) ”’That’s okay”’

11.What is the result of cmp(3, 1)?


a)1
b)0
c)True
d) False

12. What is the output when following statement is executed ?

>>>"a"+"bc"
a)a
b)bc
c)bca
d) abc

13. What is the output when following code is executed ?

>>>print r"\nhello"

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

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}

15.Which keyword is use for function?


a)Fun
b)Define
c)Def
d) Function

16. Which of the following function of dictionary gets all the keys from the
dictionary?

a) getkeys()

b) key()

c) keys()

d) None of the above.

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

17. Suppose you run the following code

N = [[9, 8, 7], [6, 5, 4], [3, 2, 1]]

print n[2]

What gets printed?

a) [6, 5, 4]

b) 2

c) 7

d) [3, 2, 1]

18. Which of the below is used for python?

a)Interpreter

b)Compiler

c)Both

19. Which of these websites are build in python?

a)Instagram

b)Pinterest

c)NASA's website

d)All

20.Which of these languages where released first?

a)Java

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

b)Python

21. What is Anaconda in python?

a) Module

b) Library

c) Object

d) function

22. What is the output of the following code in python

print 'hello'[::-1]

a)olleh

b)hello -1

c)o

d)Error

23. Select all options that print


hello-how-are-you
a) print(‘hello’, ‘how’, ‘are’, ‘you’)
b) print(‘hello’, ‘how’, ‘are’, ‘you’ + ‘-‘ * 4)
c) print(‘hello-‘ + ‘how-are-you’)
d) print(‘hello’ + ‘-‘ + ‘how’ + ‘-‘ + ‘are’ + ‘you’)

24. Suppose t = (1, 2, 4, 3), which of the following is incorrect?

a) print(t[3])
b) t[3] = 45
c) print(max(t))
d) print(len(t))

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

25. What will be the output?

>>>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)

26. What will be the output?

d = {"john":40, "peter":45}

"john" in d
a) True
b) False
c) None
d) Error

27. What will be the output?

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)

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

28. What is the output when following code is executed ?

>>>names = ['Amir', 'Bear', 'Charlton', 'Daman']

>>>print(names[-1][-1])

a) A
b) Daman
c) Error
d) n

29. Suppose d = {“john”:40, “peter”:45}. To obtain the number of entries in


dictionary which command do we use?
a) d.size()
b) len(d)
c) size(d)
d) d.len()

30Suppose list1 is [3, 4, 5, 20, 5, 25, 1, 3], what is list1.count(5) ?


a) 0
b) 4
c) 1
d) 2

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

You might also like