Source: Online social media and website

Module creation

User defined module

A module is a file containing Python definitions and statements. The file name is the module name with the suffix .py appended. Within a module, the module’s name (as a string) is available as the value of the global variable __name__. For instance, use your favorite text editor to create a file called fibo.py in the current directory (C:\Users\****\AppData\Local\Programs\Python\Python36-32\Lib) with the following contents: 




def fib2(n):   # return Fibonacci series up to n

    result = []
    a, b = 0, 1
    while b < n:
        result.append(b)
        a, b = b, a+b
    return result
 

Now enter the Python interpreter and import this module with the following command:



Standard module

Access windows DOS commands

You can execute the Disk Operation System (DOS) commands in python IDLE.




2 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. This programmatic information has given by which is very helpful for who are looking for python training in Hyderabad

    ReplyDelete