1def main():
2 print("Hello World!")
3
4if __name__ == "__main__":
5 main()
1# Defining main function
2def main():
3 print("hello World")
4
5
6# Using the special variable
7# __name__
8if __name__=="__main__":
9 main()
1
2print("Hello")
3
4print("__name__ value: ", __name__)
5
6
7def main():
8 print("python main function")
9
10
11if __name__ == '__main__':
12 main()
13
1 1from time import sleep
2 2
3 3print("This is my file to demonstrate best practices.")
4 4
5 5def process_data(data):
6 6 print("Beginning data processing...")
7 7 modified_data = data + " that has been modified"
8 8 sleep(3)
9 9 print("Data processing finished.")
1010 return modified_data
1111
1212def read_data_from_web():
1313 print("Reading data from the Web")
1414 data = "Data from the web"
1515 return data
1616
1717def write_data_to_database(data):
1818 print("Writing data to a database")
1919 print(data)
2020
2121def main():
2222 data = read_data_from_web()
2323 modified_data = process_data(data)
2424 write_data_to_database(modified_data)
2525
2626if __name__ == "__main__":
2727 main()
28