main() function:
- By default, every program starts its execution from the main() function. In Python including a main() function is not mandatory.
- It can structure our Python in a logical way that puts components of the program the most in one program's important function.
- We can get the name of the current module executing by using the built-in variable name (2 underscores before and after of name).
- Most non-python programmers are having the habit of writing a main()function where the important and starter code of programs are written.
- In Python, we can also create main() and call it by checking name to main and then call any function, in this case main().
Example program:
Output:
No comments:
Post a Comment