07th
May
Python MCQ

Python MCQ

  • Admin
  • 07th May, 2021
  • 1024 Followers

Python MCQ Quiz

Following are mostly asked Python MCQ test that are designed for professionals like you to crack you interviews. You can take this Python online test before appearing to you real interview. This Python quiz there are around 30+ multiple choice questions on Python with four options.

1) Is Python case sensitive when dealing with identifiers?

  • A. Yes
  • B. No

2) Is Python case sensitive when dealing with identifiers?

  • A. yes
  • B. no
  • C. machine dependent
  • D. none of the mentioned

3) What is the maximum possible length of an identifier?

  • A. 79 characters
  • B. 31 characters
  • C. 63 characters
  • D. none of the mentioned

4) Which of the following is an invalid variable?

  • A. foo
  • B. my_string_1
  • C. 1st_string
  • D. _

5) Which of the following is not a keyword?

  • A. pass
  • B. assert
  • C. nonlocal
  • D. eval
Download Free : Python MCQ PDF

6) Which of the following is invalid?

  • A. __str__ = 1
  • B. _a = 1
  • C. __a = 1
  • D. none of the mentioned

7) All keywords in Python are in _________

  • A. UPPER CASE
  • B. Capitalized
  • C. lower case
  • D. None of the mentioned

8) Which of the following is an invalid statement?

  • A. a b c = 1000 2000 3000
  • B. a,b,c = 1000, 2000, 3000
  • C. abc = 1,000,000
  • D. a_b_c = 1,000,000

9) Which of the following cannot be a variable?

  • A. __init__
  • B. in
  • C. it
  • D. on

10) Which one of these is floor division?

  • A. //
  • B. /
  • C. %
  • D. None of the mentioned

11) What is the answer to this expression, 22 % 3 is?

  • A. 7
  • B. 1
  • C. 5

12) Which one of the following has the same precedence level?

  • A. Addition and Subtraction
  • B. Multiplication, Division and Addition
  • C. Multiplication, Division, Addition and Subtraction
  • D. Addition and Multiplication

13) Which one of the following has the highest precedence in the expression?

  • A. Exponential
  • B. Multiplication
  • C. Parentheses
  • D. Addition

14) Which of these in not a core data type?

  • A. Class
  • B. Lists
  • C. Tuples
  • D. Dictionary

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

  • A. int
  • B. None
  • C. bool
  • D. void

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

17) What is the return type of function id?

  • A. float
  • B. bool
  • C. int
  • D. dict

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

  • A. list
  • B. dictionary
  • C. class
  • D. tuple

19) Which of the following results in a SyntaxError?

  • A. ‘3\’
  • B. “He said, ‘Yes!'”
  • C. ‘”Once upon a time…”, she said.’
  • D. ”’That’s okay”’

20) What is the output of print 0.1 + 0.2 == 0.3?

  • A. True
  • B. False
  • C. Machine dependen
  • D. Error

21) Which of the following is not a complex number?

  • A. k = 2 + 3j
  • B. k = complex(2, 3)
  • C. k = 2 + 3l
  • D. k = 2 + 3J

22) What is the type of inf?

  • A. Complex
  • B. Float
  • C. Boolean
  • D. Integer

23) What does ~4 evaluate to?

  • A. -3
  • B. -4
  • C. -5
  • D. +3

24) Which of the following is incorrect?

  • A. x = 0b101
  • B. x = 0x4f5
  • C. x = 19023
  • D. x = 03964

25) What does 3 ^ 4 evaluate to?

  • A. 7
  • B. 12
  • C. 0.75
  • D. 81

26) Which of the following operators has its associativity from right to left?

  • A. +
  • B. **
  • C. %
  • D. //

27) Which of the following expressions involves coercion when evaluated in Python?

  • A. 1.7 % 2
  • B. 4.7 – 1.5
  • C. 7.9 * 6.3
  • D. 3.4 + 4.6

28) Which of the following expressions results in an error?

  • A. float(‘10’)
  • B. int(’10.8’)
  • C. int(‘10’)
  • D. float(’10.8’)

29) What will be the output of the following Python expression?

  • A. ‘0b10111’
  • B. ‘0b11111’
  • C. ‘0b11011’
  • D. ‘0b11101’

30) Which of the following expressions results in an error?

  • A. int(‘1011’)
  • B. int(1011,2)
  • C. int(‘1011’,23)
  • D. int(1011)

31) Which of the following expressions can be used to multiply a given number ‘a’ by 4?

  • A. a<<4
  • B. a>>2
  • C. a<<2
  • D. a>>4

32) What will be the output of the following Python code?

  • A. Error
  • B. No output
  • C. t
  • D. f

33) What will be the output of the following Python code snippet?

  • A. No output
  • B. Error
  • C. True
  • D. False

34) The expression shown below results in an error.

  • A. True
  • B. False

35) What will be the output of the following Python code?

  • A. {‘san’, ‘foundry’}
  • B. san foundry
  • C. sanfoundry
  • D. Error

36) Select the valid option for the following Output −

  • A. Canvas.Create_text(text= ''Hello! ''
  • B. Canvas.Create_text(30 , 40, text= ''Hello! '' ,filled= ''green ''
  • C. Canvas.Create_text(text= ''Hello! '' ,textcolor= ''Green''
  • D. Canvas.Create_text(30 , 40, text= ''Hello!''

37) What will be the output of the following Python code if the input entered is 6?

  • A. Bye (printed once)
  • B. Invalid (printed once)
  • C. No output
  • D. Bye (printed infinite number of times)

38) Which of the following is not a standard exception in Python?

  • A. NameError
  • B. AssignmentError
  • C. IOError
  • D. ValueError

39) An exception is ____________

  • A. a standard module
  • B. a special function
  • C. a module
  • D. an object

40) Which of the following blocks will be executed whether an exception is thrown or not?

  • A. except
  • B. finally
  • C. else
  • D. assert

Python Online Test Questions (Python FAQs)

1) What is lambda function in Python?

In the world of Python, this is a single line functioning that has been declared without any name which shall have some arguments and a single expression. With this function, you can use it like the regular one with Python's def keyword

2) What is use of Python isinstance()?

The isinstance() function checks if the object (first argument) is an instance or subclass of classinfo class (second argument).

Syntax

isinstance(object, classinfo)

3) What are operators in python?

Operators signifies in Python that carry out the logical blend and been the arithmetic one. The operator operates the value which is called as the operand.

4) What will be the output of 7^10 in python?

13 will be the output of 7^10 in python.

5) How to convert bytes to int or int to bytes in python?

A bytes object can be converted to an integer value easily using Python. You can use from_bytes() method to do that.

Syntax

int.from_bytes(bytes, byteorder, *, signed=False)

6) How to flatten a list of lists in one line in Python?

You can use below code to flatten a list of lists in one line in Python

#The list of lists
list_of_lists = [range(4), range(7)]

#flatten the lists
flattened_list = [y for x in list_of_lists for y in x]

7) List some reserved keywords in python?

assert, break, class, continue, def are few reserved keywords in python.

8) What is python numba?

Python numba is one open-source JIT complier which helps in translating a python subset and the Numpy in the last machine code with the use of LLVM through limited Python package. It gives wide range of choices to the python code for GPU and CPU but with few changes.

9) What is python pip?

PIP is one package manager for modules and even the Python packages. You might get this as a default if you have Python version 3.4 or later.

10) What are python modules?

A module is a Python object with arbitrarily named attributes that you can bind and reference.

11) What is sequencing in Python?

In Python, sequence is the generic term for an ordered set. There are several types of sequences in Python Lists, strings, and Tuples three are the most important.

12) What is interactive mode in python?

The interactive mode in Python involves running your codes directly on the Python shell which can be accessed from the terminal of the operating system.

13) How to use selection statements in python?

The selection statement is also called as the statement of decision making or even the branch statement. It can help on selecting the program part which has to be executed depending on the situation.

14) What is PYTHON PATH?

Python Path is one kind of an environment variable that a user can set for additional directories that a user needs the python to the directly list

15) What is self in Python?

self represents the instance of the class. By using the “self” keyword we can access the attributes and methods of the class in python.

Leave A Comment :

Valid name is required.

Valid name is required.

Valid email id is required.

Related MCQ/Quiz

01st
May
AngularJs MCQ
01st
May
Java MCQ
01st
May
SEO MCQ
01st
Apr
NoSQL MCQ
01st
Apr
Cobol MCQ
01st
May
TensorFlow MCQ