Featured post

How to Use Special Keys in UNIX

UNIX operating system has some special keys. These you can use to interrupt the program processing or to resume it. The file management and keys totally different in UNIX kinds of operating systems. 

An example of a UNIX special key and its use.
Why You Need Interruption
A scenario where you made some mistake in the input command and you need to stop the further process. Then you can use the CTRL+C command. It is equal to the DELETE command.

List of UNIX Special Keys

RETURN key — The RETURN key signifies the end of a line of input. On any terminal, RETURN has a key of its own, or return may be typed by holding down the control key and typing a 'm'.Ctrl-m
Hint: Ctrl-m command is equal to RETURN key in Unix systems

DELETE: The DELETE key stops a program/command immediately, without waiting for it to finish. DELETE can be achieved equivalently with ctrl-c.
Hint: Ctrl-c Command you can use to interrupt the process.

Ctrl-s: Ctrl-s pauses the output and the program is suspended until you sta…

Ideas to Find Factorial in Python

In Python, writing script is the main task. This post tells you how to find factorial using python.

python factorial logic

A module is created as a script file, which contains function definitions that can be called in two ways:
  • From the interpreter 
  • From another script file or from another function

How to import

What is the process. You can just save the below script as fact.fy

In interpreter...
>>> import fact
# This program illustrates the designing/creation of a module

def factorial(n):
        "This module computes factorial"
        for i in range (1, n+1):

What is reloading the script

The Python interpreter imports a module only once in a session. 

If some modifications are performed in the module script then it must be reloaded (imported) again in the interpreter for further use.

A script is reusable component and you can add n number of functions inside of it.

Directory function

In order to see the list of function names defined in a module, Python is provided with a built-in function called dir(). It displays the list of all the function definition names as follows:

['__builtins__', '__cached__', '__doc__', '__file__', 
'__loader__','__name__', '__package__','__spec__',

Another way if we give 'module' name in dir(), you will get a list of all functions inside of it.

Also, read


Popular posts from this blog

10 Top Unix Disk Space Quiz Questions

How to Categorise Python Top Uses

Python Function: How to Write Error Logic