Chapter 14
Chapter 14
SCHOOL
M.V. SOUTH, ATTUR.
CHAPTER 14 – IM PORTING C++ PROGRAMS IN PYTHON
PART A
CHOOSE THE BEST ANSW ER
1. Which of the following is not a scripting language?
a) JavaScript b) PHP c) Perl d) HTML
2. Importing C++ program in a Python program is called
a) wrapping b) Downloading c) Interconnecting d) Parsing
3. The expansion of API is
a) Application Programming Interpreter b) Application Programming Interface
c) Application Performing Interface d) Application Programming Interlink
4. A framework for interfacing Python and C++ is
a) C types b) SWIG c) Cython d) Boost
5. Which of the following is a software design technique to split your code into separate
parts?
a) Object oriented Programming b) Modular programming
c) Low Level Programming d) Procedure oriented Programming
6. The module which allows you to interface with the Windows operating system is
a) OS module b) sys module c) csv module d) getopt module
7. getopt() will return an empty array if there is no error in splitting strings to
a) argv variable b) opt variable c) args variable d) ifile variable
8. Identify the function call statement in the following snippet.
if __name__ =='__main__':??
main(sys.argv[1:])
a) main(sys.argv[1:]) b) __name__ c) __main__ d) argv
9. Which of the following can be used for processing text, numbers, images, and scientific
data?
a) HTML b) C c) C++ d) PYTHON
10. What does __name__ contains?
a) c++ filename b) main () name c) python filename d) os module name
11. Which of the following are general purpose programming language?
a) Python b) C++ c) Java d) All of these
12. Which of the following is not general purpose language?
a) Python b) C++ c) Perl d) Java
13. Which of the following is not a compiled statically typed language?
a) C++ b) Python c) Java d) All of these
14. In which language datatype or not required while declare variable?
a) Python b) C++ c) C d) Java
15. Which of the following can act both as scripting and general purpose language?
a) Html b) Python c) C d) C++
16. Which programming language is useful when the logic can be written in C++ and
manipulated through python program?
a) C++ b) Html c) Perl d) Python
17. Which is a programming language designed for integrating and communicating with
other programming languages?
K.SIVAPRAKASAM M.SC.,M.PHIL.,B.ED., PGT IN CS, PAAVENDHAR MHSS-M.V.SOUTH, ATTUR 636121 Page 1
a) Procedural language b) Modular language
c) Scripting language d) none of these
18. Which of the following is a scripting language?
a) Ruby b) ASP c) TCl d) All of these
19. Which of the following language used automatic garbage collection?
a) C++ b) Java c) Python d) C
20. A scripting language requires
a) Interpreter b) Python c) Compiler d) Modules
21. A programming language requires
a) Compiler b) Interpreter c) Modules d) Scripts
22. C++ code is 5 to 10 times more than
a) Java b) Java script c) Python d) C
23. How many ways are there to create python interface?
a) 4 b) 3 c) 5 d) Many
24. Which of the following interface used for interfacing with C programs?
a) Ctypes b) MinGW c) Boost d) Cython
25. SWIG expansion is
a) Software Wrapper Information Generator b) System Wrapper Interface Generator
c) Simplified Wrapper Interface Generator d) None of these
26. Which of the following python interface used for both C and C++?
a) MinGW b) Ctypes c) Cython d) SWIG
27. MinGW expansion is
a) Minimalist GNU for windows b) Minimalist Graphics for windows
c) Minimum GNU for windows d) Motion Graphics for windows
28. Which of the following is needed to run a C++ program on windows?
a) m++ b) f++ c) g++ d) ghre++
29. The command to change to the folder where Python is located is
a) Change b) CD c) Dir d) CDir
30. The syntax to execute the python program is
a) Python - i < filename.py > < c++ filename >
b) Python < filename - py > < C++ filename > - i
c) Python < C++ filename > - i < filename.py >
d) Python < filename.py > < C++ filename >
31. In the command python < filename.py > - i < C++ filename > where i denotes.
a) Information b) Interpreter c) Input mode d) ios
32. Which of the following is not a python module?
a) Tel b) OS c) Sys d) Getopt
33. The operator used to access the python functions using modules is
a) ; b) . c) :: d) ,
34. Which of the following is not a python module?
a) Sys b) OS c) Getopt d) g++
35. Which of the following is a python module?
a) Sys b) OS c) Getopt d) All of these
36. Which of the following is an array holding the command line arguments of the
program?
a) g++ b) argv c) Opts d) Getopt
K.SIVAPRAKASAM M.SC.,M.PHIL.,B.ED., PGT IN CS, PAAVENDHAR MHSS-M.V.SOUTH, ATTUR 636121 Page 2
37. How many options getopt provides to enable command line argument parsing?
a) 2 b) 3 c) 4 d) 7
38. Getopt() method returns values are started in
a) Opts b) Args c) Sys d) a and b
39. Which of the following is a built - in variable which evaluates to the name of the current
module?
a) - - main - - b) - - name - - c) - - getopt - - d) - - sys - -
40. The mode 'i'/'o' parses each values of the command line and pass as argument to the
list called
a) Args b) Sys c) Opts d) Argv
41. Which of the following definition invoke the 'g++' compiler and creates the exe file?
a) Run b) Main c) Name d) System
42. ______ is typically interpreted language.
a) C++ b) Python c) Java d) None of these
43. ________ is mostly used as a 'glue' language.
a) CSV b) C++ c) Java d) Python
44. _________ is both a python like language for writing C extensions.
a) Boost b) Ctypes c) SWIG d) Cython
45. ________refers to a set of runtime header files used in compiling and linking the C++
code to be run or window OS?
a) MinGW b) SWIG c) Cython d) Boost
46. ______ version of MinGW is the best compiler for C++ on windows.
a) W32 b) W256 c) W64 d) W128
47. __________ allows to compile and execute C++ program dynamically through python
program using g++.
a) SWIG b) MinGW c) Ctypes d) Boost
48. ________ is a program that calls GCC for linking the C++ library files to the object code.
a) C++ b) C c) Python d) g++
49. ________ refers to the complete path where python is installed.
a) Relative path b) Directory path c) Python path d) Absolute path
50. ________ is a software design technique to split the code into separate parts.
a) Procedural programming b) Modular Programming
c) Structural programming d) Object Oriented Programming
51. ___________ refers to a file containing python statements and definitions?
a) Modules b) Procedures c) Structures d) Objects
52. ________ is the list of command-line argument passed to the python program?
a) OS.system() b) Getopt.getopt() c) Sys.argv d) Next()
53. To use sys.argv, you have to ______
a) Import CSV b) Import sys c) Import.+ py d) Include sys
54. _________ symbol is os.system() indicates that all strings are concatenated and send
that as a list.
a) - b) () c) . d) +
55. ____ module of python helps you to split command line options and arguments.
a) OS b) Getopt c) Sys d) All of these
56. ______ method returns value consisting of two elements.
a) sys.argv b) getopt() c) OS.system() d) none of these
K.SIVAPRAKASAM M.SC.,M.PHIL.,B.ED., PGT IN CS, PAAVENDHAR MHSS-M.V.SOUTH, ATTUR 636121 Page 3
57. ________ is one such special variable which by default stores the name of the file.
a) - - name - - b) - - main - - c) - - getopt - - d) - - sys - -
58. ________ command of 'os' module executes the exe file to get the desired output.
a) Main() b) System() c) Name() d) Run()
59. The command to clear the window screen is___________
a) Clear b) Cls c) Clr d) Clrscr
60. The keyword used to import the module is _________
a) Include b) Import c) Input d) None of these
61. Choose the incorrect statement from the following.
i. C++ program needs to be compiled before running.
ii. Python need to be compile(d)
iii. Perl, Ruby, ASP are the scripting languages.
iv. Python is not high-level general purpose programming language.
a) ii and iv b) i and ii c) ii and iii d) i, ii and iv
62. Python is mostly used as__________language.
a) High level b) Scripting c) glue d) B or C
63. What is the name called, python deletes unwanted objects automatically to free the
memory space?
a) Recycle b) Garbage collection c) Interface d) Wrapping
64. Which mode is specify to input or output in python?
a) '-o' b) '-i' c) '-a' d) '-s'
65. Which method is used to returns values consisting of two values?
a) append() b) extend() c) getopt() d) insert()
66. Which interface is used for python-like language for writing c-extensions?
a) Cython b) Boost c) MinGW d) SWIG
67. Which language is used both as scripting and general purpose language?
a) C b) C++ c) Python d) HTML
68. Which programming language is designed for integrating and communicating with
other programming language?
a) Modular language b) Procedural language
c) Scripting language d) High level language
69. Which of the following is not a scripting language?
a) Ruby b) TCI c) ASP d) COBOL
70. Which requires a programming language?
a) Compiler b) Interpreter c) Editor d) Exefile
71. Which is requires a scripting language?
a) Compiler b) Interpreter c) Editor d) Exefile
72. Which of the following interface used for interfacing with C programs?
a) Cython b) Ctypes c) MinGw d) SWIG
73. Which of the following python interface used for both C and C++?
a) Cython b) Ctypes c) MinGw d) SWIG
74. Which is needed to run a C++ program on windows?
a) m++ b) g++ c) e++ d) f++
75. Which of the following is not a python module?
a) sys b) g++ c) os d) Getopt
76. Which version of MinGW is the best compiler for C++ on windows?
a) W32 b) W64 c) W128 d) W256
77. Which interface to a set of runtime header files, used compiling and linking the code
of C, C++?
a) SWIG b) MinGW c) Cython d) Ctypes
K.SIVAPRAKASAM M.SC.,M.PHIL.,B.ED., PGT IN CS, PAAVENDHAR MHSS-M.V.SOUTH, ATTUR 636121 Page 4
78. g++ is a____
a) module b) program c) scope d) identifier
79. Which command is used to clear the screen in window?
a) cls b) clear c) cs d) cl
80. Which operator is used to access the function?
a) (.)dot b) (:)colon c) (,)comma d) (;)semi colon
81. Which is mostly used as a 'glue' language?
a) C b) C++ c) Java d) Python
ANSW ER KEY
1. d) HTML 22. c) Python 43. d) Python 66. a) Cython
2. a) wrapping 23. d) Many 44. d) Cython 67. a) C
3. b) Application 68. a) Modular
24. a) Ctypes 45. a) MinGW
Programming Interface language
25. c) Simplified
4. d) Boost Wrapper Interface 46. c) W64 69. d) COBOL
Generator
5. b) Modular
26. d) SWIG 47. b) MinGW 70. a) Compiler
programming
PART B
1. W hat is the theoretical difference between Scripting language and other
programming language?
The theoretical difference between the two is that scripting languages do not require
the compilation step and are rather interpreted.
For example, normally, a C++ program needs to be compiled before running
whereas, a scripting language like JavaScript or Python need not be compiled.
Compiler Interpreter
Scans the entire program and
Translates program one statement
i. translates it as a whole into
at a time.
machine code.
It takes large amount of time to
It takes less amount of time to
analyze the source code but the
ii. analyze the source code but the
overall execution time is
overall execution time is slower.
comparatively faster.
Data type is not required while Data type is required while declaring
3
declaring variable variable
welcome.display()
Function call
Dot operator
Module name