Sample Code Python
Sample 1:
def main():
print "Hello Folks!"
print "Welcome to Python Programming"
Sample 1 - Output:
Welcome to Python Programming
Reason:
It is Important that after defining the main function, you call the code by
if__name__=="__main__"
and then run the code, only then you will get the output "hello Folks" in console
Sample 2:
def main():
print "Hello Folks!"
if __name__== "__main__":
main()
print "Welcome to Python Programming"
Sample 2 - Output:
Hello Folks!
Welcome to Python Programming
Sample 1:
def main():
print "Hello Folks!"
print "Welcome to Python Programming"
Sample 1 - Output:
Welcome to Python Programming
Reason:
It is Important that after defining the main function, you call the code by
if__name__=="__main__"
and then run the code, only then you will get the output "hello Folks" in console
Sample 2:
def main():
print "Hello Folks!"
if __name__== "__main__":
main()
print "Welcome to Python Programming"
Sample 2 - Output:
Hello Folks!
Welcome to Python Programming
No comments:
Post a Comment