Python Byte Code Basics Interview MCQ Questions and Answers

Study and learn Interview MCQ Questions and Answers on Python Byte Code basics. Attend job interviews easily with these Multiple Choice Questions. You can print these Questions in default mode to conduct exams directly. You can download these MCQs in PDF format by Choosing Print Option first and Save as PDF option next using any Web Browser.

Go through Python Theory Notes on Compiling Running and Python Theory Notes on Byte Code before reading these objective questions.



1) What is the file name extension of a Python Program?
A) .PY
B) .PYC
C) .PYB
D) .PYBY
Answer [=]
Answer[=]
2) What is the file name extension of a Python Byte Code file?
A) .PYB
B) .PYC
C) .PYBY
D) .PYB
Answer [=]
Answer[=]
3) What is the size of a single byte code instruction in Python?
A) 1 KB
B) 1 Byte
C) 4 Bits
D) 1024 Bytes
Answer [=]
Answer[=]
4) Which is the module used to generate Python Bytecode from source code?
A) py_bytecode
B) py_compile
C) pyparse
D) pyshell
Answer [=]
Answer[=]
5) py_compile is a ______ module.
A) Built-in module
B) Third party module
C) --
D) --
Answer [=]
Answer[=]
6) Which is the command used to generate Python Byte code?
A) py_compile
B) python
C) pydoc
D) pyshell
Answer [=]
Answer[=]
7) Where can you locate Python Byte Code files?
A) Inside the same directory
B) __pycache__ directory of the program's directory
C) C:\Program Files>
D) C:\Windows
Answer [=]
Answer[=]


 

8) What is the file name convention of generated Byte Code file?
A) PROGRAM_NAME.PYC
B) PRGRAM_NAME_PYTHON_VERSION.PYC
C) PROGRAM_NAME.CPYTHON-PYTHON_VERSION.PYC
D) PROGRAM_NAME.CPYTHON.PYC
Answer [=]
Answer[=]
9) Which is the module used to view Python Byte code?
A) py_compile
B) python
C) dis
D) opcode
Answer [=]
Answer[=]
10) What is a DIS module in python?
A) Disassembler
B) display
C) discloser
D) None of the above
Answer [=]
Answer[=]
11) Identify byte code instructions below?
A) LOAD_NAME
B) LOAD_CONST
C) CALL_FUNCTION
D) All the above
Answer [=]
Answer[=]
12) Identify Byte Code instructions below.
A) POP_TOP
B) CALL_FUNCTION
C) RETURN_VALUE
D) All the above
Answer [=]
Answer[=]
13) Choose a Byte Code instruction file below.
A)
  0           0 RESUME                   0

  1           2 LOAD_CONST               0 (5)
              4 STORE_NAME               0 (a)
              6 LOAD_CONST               1 (10)
              8 STORE_NAME               1 (b)

  2          10 PUSH_NULL
             12 LOAD_NAME                2 (print)
             14 LOAD_NAME                0 (a)
             16 LOAD_NAME                1 (b)
             18 BINARY_OP                0 (+)
             22 PRECALL                  1
             26 CALL                     1
             36 POP_TOP
             38 LOAD_CONST               2 (None)
             40 RETURN_VALUE
B)
  0           0 RESUME                   0

  1           2 PUSH_NULL
              4 LOAD_NAME                0 (print)
              6 LOAD_CONST               0 ('This is to say hi..!')
              8 PRECALL                  1
             12 CALL                     1
             22 POP_TOP
             24 LOAD_CONST               1 (None)
             26 RETURN_VALUE
C)
 0           0 RESUME                   0

  1           2 LOAD_CONST               0 (2)
              4 STORE_NAME               0 (a)

  2           6 LOAD_NAME                0 (a)
              8 LOAD_CONST               1 (0)
             10 COMPARE_OP               4 (>)
             16 POP_JUMP_FORWARD_IF_FALSE    24 (to 66)

  3     >>   18 PUSH_NULL
             20 LOAD_NAME                1 (print)
             22 LOAD_NAME                0 (a)
             24 PRECALL                  1
             28 CALL                     1
             38 POP_TOP

  4          40 LOAD_NAME                0 (a)
             42 LOAD_CONST               2 (1)
             44 BINARY_OP               10 (-)
             48 STORE_NAME               0 (a)

  2          50 LOAD_NAME                0 (a)
             52 LOAD_CONST               1 (0)
             54 COMPARE_OP               4 (>)
             60 POP_JUMP_BACKWARD_IF_TRUE    22 (to 18)
             62 LOAD_CONST               3 (None)
             64 RETURN_VALUE
        >>   66 LOAD_CONST               3 (None)
             68 RETURN_VALUE
D) All the above
Answer [=]
Answer[=]


Like or Share

Show some care. Like or Subscribe. [FB]...[Youtube]

C MCQ App by ExamTray 

Android APP

Java MCQ App by ExamTray 

Android APP
ALL MCQ App by ExamTray Android APP

Ad