📖 generic · 12th TN - English Medium · COMPUTER SCIENCE · Page 268question

Refer installation of MinGW in Annexure -2 · Part 2

Chapter 4: 6 · COMPUTER SCIENCE

for the files during execution. The output is displayed below C:\Program Files\migw-w64\i686- . . -posix-dwarf- -rev0>echo off Microsoft windows [Version .

. ] copy right <c> Microsoft Corporation. All rights reserved. C:\>cd Pyprg C:\Pyprg> Python c:\pyprg\pycpp.py-i c:\pyprg\pali Enter apositive number: The reverse of the number is: The number is a palindrome C:\Pyprg> Python c:\pyprg\pycpp.py -i c:\pyprg\pali Enter a positive number: The reverse of the number is: The number is not a palindrome C:\Pyprg> Fig .

12th Computer Chapter - - To clear the screen in command window use cls command Note Now let us will see how to write the Python program for compiling C++ code. Python Program to import C++ . Python contains many modules. For a problem Python allow programmers to have the flexibility in using different module as per their convenience.

The Python program what we have written contains a few new commands which we have not come across in basic Python program. Since our program is an integration of two different languages, we have to import the modules like os, sys and getopt. . .

MODULE Modular programming is a software design technique to split your code into separate parts. These parts are called modules. The focus for this separation should have modules with no or just few dependencies upon other modules. In other words: Minimization of dependencies is the goal.

But how do we create modules in Python? Modules refer to a file containing Python statements and definitions. A file containing Python code, for e.g. factorial.py, is called a module and its function name would be fact ().

We use modules to break down large programs into small manageable and organized program. Furthermore, modules provide reusability of code. We can define our most used functions in a module and import it, instead of copying their definitions into different programs. def fact(n): f= if n == : return elif n == : return else: for i in range( , n+ ): f= f*i print (f) Output: >>>fact ( ) Example: The above example is named as factorial.py 12th Computer Chapter - - Importing C++

Related topics

Have a question about this topic?

Get an AI answer grounded in your actual textbook — with the exact page reference.

Ask AI about this topic →