Chapter 14: Importing C++ Programs in Python — Online MCQ Test
COMPUTER SCIENCE · CLASS 12th · Tamil Nadu State Board
Practice Chapter 14: Importing C++ Programs in Python with a free chapter-wise online MCQ test.
This chapter covers: Exploring language interoperability this chapter explains wrapping and executing C++ source code inside Python using the g++ compiler and getopt module. It details performance bene....
AI-generated questions from basic to board-exam level, with instant results and explanations.
Chapter 14: Importing C++ Programs in Python — Important Questions & Answers
Which compiler is used to compile C++ source code when importing it into Python as described in this chapter?
- A. g++
- B. javac
- C. gcc
- D. py_compile
Answer: A. g++
The chapter explains that C++ source code is compiled using the g++ compiler before it is used from Python.
The chapter explains that C++ source code is compiled using the g++ compiler before it is used from Python.
What is the main purpose of importing C++ programs into Python?
- A. To replace Python completely
- B. To reuse C++ code inside Python programs
- C. To convert Python into machine code
- D. To create only web pages
Answer: B. To reuse C++ code inside Python programs
Importing C++ programs into Python helps reuse existing C++ code and combine the strengths of both languages.
Importing C++ programs into Python helps reuse existing C++ code and combine the strengths of both languages.
Why is using C++ code inside Python sometimes preferred for certain tasks?
- A. Because C++ is always easier to write than Python
- B. Because it can improve performance for computation-heavy tasks
- C. Because Python cannot run without C++
- D. Because C++ removes the need for variables
Answer: B. Because it can improve performance for computation-heavy tasks
C++ can execute time-consuming operations faster, so it is useful for performance-critical parts of a program.
C++ can execute time-consuming operations faster, so it is useful for performance-critical parts of a program.
Which of the following is NOT a benefit of importing C++ programs into Python?
- A. Code reuse
- B. Better performance for some tasks
- C. Combining features of both languages
- D. Eliminating the need to compile C++
Answer: D. Eliminating the need to compile C++
C++ code still needs to be compiled; importing does not remove the compilation step.
C++ code still needs to be compiled; importing does not remove the compilation step.
Which option correctly matches the concept with its purpose?
- A. g++ — command-line parsing
- B. getopt — compiling C++ source code
- C. g++ — compiling C++ source code
- D. shared object file — Python syntax checking
Answer: C. g++ — compiling C++ source code
g++ is the compiler used for C++ source code; the other options mismatch the tools and their functions.
g++ is the compiler used for C++ source code; the other options mismatch the tools and their functions.