12th Standard Syllabus & Materials
12th Standard
TN 12th Computer Applications மின்னணு தரவு பரிமாற்றம் Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications மின் - வணிக பாதுகாப்பு அமைப்புகள் Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications மின்னணு செலுத்தல் முறைகள் Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications மின் - வணிகம் Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications திறந்த மூல கருத்துருக்கள் Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications வலையமைப்பு வடமிடல் Sample Question Papers Study Material - QB365 Set A

Published on: 14/10/2019
Importing C++ Programs in Python
Download Tamil Nadu 12th Standard Computer Science question papers, model tests, one-mark questions, important questions, and public exam papers in PDF format. Free study materials and answer keys for TN State Board students.
Questions + Answers key
Take MCQ Computer Science Test

1.
What is sys.argv? What does it contain?
2.
Identify the module, operator, definition name for the following
welcome.display().
3.
What is MinGW? What is its use?
4.
What are the applications of scripting language?
5.
Differentiate PYTHON and C++.
6.
Write a Python program to execute the following c++ coding.
#include <iostream>
using namespace std;
int main()
{ cout<<“WELCOME”;
return(0);
}
The above C++ program is saved in a file welcome.cpp
7.
Write the syntax for getopt( ) and explain its arguments and return values.
8.
9.
Explain each word of the following command.
Python
10.
Write any 5 features of Python.
1.
sys.argv is the list of command-line arguments passed to the Python program. argv contains all the items that come along via the command-line input, it's basically an array holding the command-line arguments of the program.
To use syss.argv, we will first have to import sys. The first argument, sys.argv [0], is always the name of the program as it was invoked and sys.argv [1] is the first argument we pass to the program.
Example:
main (sys.argv [1]) - Accepts the program file and the input file as a list. argv[0] contains the python program which is need not to be passed because by default _main_contains source code reference and argv[1] contains the name of the C++ file which is to be processed.
2.
welcome → module name
● → operator name
display() → definition name
3.
(i) MinGW refers to a set of runtime header files, used in compiling and linking the code of C, C++ and FORTRAN to be run on Windows Operating System.
(ii) MinGw- W64 (version of MinGW) is the best compiler for C++ on Windows. To compile and execute the C++ program, need 'g++' for Windows. MinGW allows to compile and execute C++ program dynamically through Python program using g++.
(iii) Python program that contains the c++ coding can be executed only through 'MinGW_w64 project' run terminal. The run terminal open the command -line window through which Python program should be executed.
(iv) g++ is a program that calls GCC (GNU C compiler) and automatically links the required C++ Library files to the object code.
4.
(i) To automate certain tasks in a program
(ii) Extracting information from a data set
(iii) Less code intensive as compared to traditional programming language
(iv) can bring new functions to applications and glue complex systems together
(v) Conjuction with other programming languages HTML, Java, C++.
5.
| S.No | PYTHON | C++ |
|---|---|---|
| (i) | Python is typically an "interpreted" language | C++ is typically a "compiled" language |
| (il) | Python is a dynamic typed language | C++ is compiled statically typed language |
| (iii) | Data type is not required while declaring variable | Data type is required while declaring variable |
| (iv) | It can act both as scripting and general purpose language | It is a general purpose language |
6.
Execution Steps:
//save above file as welcome.cpp
#Now select File -> New in Notepad and type the Python program
#save the file as fun.py
#Program that compiles and executes a .cpp file
#Python fun.py- iC: |pyprg| welcome - file.cpp
Program:
import sys, os, getopt
def main (argv):
cpp_file="
exe_file="
opts, args = getopt.getopt(argv, "i:", ['ifile='])
for o a in opts
if o in ("-i, "--ifile"):
cpp_file=a+ .'cpp'
exe_file = a+ 'exe'
run (cpp_file, exe_file)
def run (cpp_file, exe_file):
print("Compiling" + Cpp_file)
os.system ('g++' + cpp_file+'_o'+exe_file)
print("Running" + exe_file)
print("---------------")
print
Os.system(exe_file)
print
if_name_=='_main_':
main (sys.argv [1:])
Output:
welcome.
7.
getopt() method returns value consisting of two elements. Each of these values are stored separately in two different list opts and args. opts contains list of splitted strings like made, path and args contains any string if at all not splitted because of wrong path or mode. args will be an empty array if there is no error in splitting strings by getopt().
Example:
The Python code which is going to execute the C++ file p4 in command line will have the getopt() method.
Syntax:
opts, args = getopt.getopt (argv, "i:", ['ifile ='])
where opts contains ('-i','c:\\pyprg\\p4')]]
-i:- option nothing but mode should be followed by
'c:\\pyprg\\p4' value nothing but the absolute path of C++ file,
Since the entire command-line commands are parsed and no leftover arguments, the second argunent args will be empty[].
8.
9.
Python < filename.py > - < i > <C++ filename without cpp extension>
| Python | Keyword to execute the Python program from command-line |
| filename.py- i | Name of the Python program to executed input mode |
| C++ filename without cpp extension | Name of C++ file to be compiled and executed |
For example type Python pycpp.py - i pali in the command prompt and press enter key. If the compilation is successful we will get the desired output. Otherwise the error will be displayed.
10.
(i) Python uses Automatic Garbage Collection whereas C++ does not.
(ii) C++ is a statically typed language, while Python is a dynamically typed language.
(iii) Python runs through an interpreter, while C++ is pre-compiled.
(iv) Python code tends to be 5 to 10 times shorter than that written in C++.
(v) In Python, there is no need to declare types explicitly where as it should be done in C++.
(vi) In Python, a function may accept an argument of any type, and return multiple values without any kind of declaration beforehand. Whereas in C++ return statement can return only one value.
12th Standard Syllabus & Materials
12th Standard
TN 12th Computer Applications களப்பெயர் முறைமை (DNS) Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications வலையமைப்பு எடுத்துக்காட்டுகள் மற்றும் நெறிமுறைகள் Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications கணினி வலையமைப்பு ஓர் அறிமுகம் Sample Question Papers Study Material - QB365 Set A
NEW12th Standard
TN 12th Computer Applications PHP-உடன் MySQL-ஐ இணைத்தல் Sample Question Papers Study Material - QB365 Set A
Tamilnadu Stateboard 12th Standard Subjects

Maths

Chemistry

Physics

Biology

Computer Science

Business Maths and Statistics

Economics

Commerce

Accountancy

History

Computer Applications

Biology

Computer Technology

Computer Applications

Computer Science

Business Maths and Statistics

Commerce

Economics

Maths

Chemistry

Physics

Computer Technology

History

Accountancy

Tamil

English

French
Tamilnadu Stateboard Standards