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:
Now enter the Python interpreter and import this module with the following command:
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:
This comment has been removed by the author.
ReplyDeleteThis programmatic information has given by which is very helpful for who are looking for python training in Hyderabad
ReplyDelete