Header Ads

PYTHON MULTIPLE CHOICE QUESTIONS ANSWERS Part 1

 

PYTHON MULTIPLE CHOICE QUESTIONS ANSWERS Part 1

1. Python was developed by

A. Guido van Rossum

B. James Gosling

C. Dennis Ritchie

D. Bjarne Stroustrup

2. Python was developed in which year?

A. 1972

B. 1995

C. 1989

D. 1981

3. Python is written in which language?

A. C

B. C++

C. Java

D. None of the above

4. What is the extension of python file?

A. .p

B. .py

C. .python

 D. None of the above

5. Python is Object Oriented Programming Language.

A. True

B. False

C. Neither true nor false

D. None of the above

6. Python 3.0 is released in which year?

A. 2000

B. 2008

C. 2011

D. 2016

7. Which of the following statements is true?

 A. Python is a high level programming language.

B. Python is an interpreted language.

C. Python is an object-oriented language

D. All of the above

 

8. What is used to define a block of code in Python?

A. Parenthesis

B. Indentation

C. Curly braces

D. None of the above

9. By the use of which character, single line is made comment in Python?

A. *

B. @

C. #

D. !

10. What is a python file with .py extension called?

A. package

B. module

C. directory

D. None of the above

11. Which of the following statements are correct?

(i) Python is a high level programming language.

(ii) Python is an interpreted language.

(iii) Python is a compiled language.

(iv) Python program is compiled before it is interpreted.

A. i, ii

B. i, iv

C. ii, iii

D. ii, iv

12. Which of the following is incorrect variable name in Python?

A. variable_1

B. variable1

C. 1variable

D. _variable

13. Is Python case sensitive when dealing with identifiers?

a) yes

b) no

c) machine dependent

d) none of the mentioned

14. What is the maximum possible length of an identifier?

a) 31 characters

b) 63 characters

c) 79 characters

d) none of the mentioned

15. Which of the following is invalid?

a) _a = 1

b) __a = 1

c) __str__ = 1

d) none of the mentioned

16. Which of the following is an invalid variable?

a) my_string_1

b) 1st_string

c) foo

d) _

17. Why are local variable names beginning with an underscore discouraged?

a) they are used to indicate a private variables of a class

b) they confuse the interpreter

c) they are used to indicate global variables

d) they slow down execution

18. Which of the following is not a keyword?

a) eval

b) assert

c) nonlocal

d) pass

19. All keywords in Python are in _________

a) lower case

b) UPPER CASE

c) Capitalized

d) None of the mentioned

20. Which of the following is true for variable names in Python?

a) unlimited length

b) all private members must have leading and trailing underscores

c) underscore and ampersand are the only two special characters allowed

d) none of the mentioned

21. Which of the following is an invalid statement?

a) abc = 1,000,000

b) a b c = 1000 2000 3000

c) a,b,c = 1000, 2000, 3000

d) a_b_c = 1,000,000

22. Which of the following cannot be a variable?

a) __init__

b) in

c) it

d) on

23. Which of these in not a core data type?

a) Lists

b) Dictionary

c) Tuples

d) Class

24. 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

25. What will be the output of the following Python code?

>>>str="hello"

>>>str[:2]

a) he

b) lo

c) olleh

d) hello

26. Which of the following will run without errors?

a) round(45.8)

b) round(6352.898,2,5)

c) round()

d) round(7463.123,2,1)

27. What is the return type of function id?

a) int

b) float

c) bool

d) dict

28. In python we do not specify types, it is directly interpreted by the compiler, so consider the

following operation to be performed.

>>>x = 13 ? 2

objective is to make sure x has a integer value, select all that apply (python 3.xx)

a) x = 13 // 2

b) x = int(13 / 2)

c) x = 13 % 2

d) All of the mentioned

29. What error occurs when you execute the following Python code snippet?

apple = mango

a) SyntaxError

b) NameError

c) ValueError

d) TypeError

30. What will be the output of the following Python code snippet?

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

31. What data type is the object below?

L = [1, 23, 'hello', 1]

a) list

b) dictionary

c) array

d) tuple

32. In order to store values in terms of key and value we use what core data type.

a) list

b) tuple

c) class

d) dictionary

33. 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”’

34. The following is displayed by a print function call. Select all of the function calls that result

in this output.

1. tom

2. dick

3. harry

a) print('''tom

 \ndick

 \nharry''')

b) print(”’tomdickharry”’)

c) print(‘tom\ndick\nharry’)

d) print('tom

 dick

 harry')

35. What is the average value of the following Python code snippet?

>>>grade1 = 80

>>>grade2 = 90

>>>average = (grade1 + grade2) / 2

a) 85.0

b) 85.1

c) 95.0

d) 95.1

36. 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’)

37. What is the return value of trunc()?

a) int

b) bool

c) float

d) None

38. How we can convert the given list into the set ?

a) list.set()

b) set.list()

c) set(list)

d) None of the above

39. If we change one data type to another, then it is called

a) Type conversion

b) Type casting

c) Both of the above

d) None of the above

40. What is list data type in Python ?

a) collection of integer number

b) collection of string

c) collection of same data type

d) collection of different data type

41. What is type casting in python ?

a) declaration of data type

b) destroy data type

c) Change data type property

d) None of the above

42. Which of the following can convert the string to float number ?

a) str(float,x)

b) float(str,int)

c) int(float(str))

d) float(str)

43. Which of the following function are used to convert the string into the list ?

a) map()

b) convertor()

c) split()

d) lambda

44. Which of the following is not the data type in python ?

a) List

b) Tuple

c) Set

d) Class

45. Which of the following is the data type possible in python?

a) int

b) list

c) dictionary

d) All of the above

46. Which of the following is the example of the type casting ?

a) int(2)

b) str(2)

c) str(list)

d) All of the above



Powered by Blogger.