Modules
Modules
Where does a Python program start?
Where does a Python program start?
def main():
print("Hello World!")
if __name__ == "__main__":
main()
https://realpython.com/python-main-function/
if __name__ == "__main__":
print("Hello from find_functions")
def find_first(values, x):
return values.index(x)
if __name__ == "__main__":
print(find_first([1, 2, 3, 1, 2, 3, 1, 2, 3], 2))
Importing code from other modules - 1
import find_functions
print("Hello from test1")
ml = [6, 7, 6, 7, 6, 7]
x = find_functions.find_first(ml, 6)
print(find_functions.MAX)
Importing code from other modules - 2
from find_functions import find_last
from find_functions import MAX
print("Hello from test2")
ml = [6, 7, 6, 7, 6, 7]
x = find_last(ml, 6)
print(x, MAX)
Importing code from other modules - 3
import find_functions as ff
from find_functions import MAX as SIXTEENCUBED
print("Hello from test3")
ml = [6, 7, 6, 7, 6, 7]
x = ff.find_middle(ml, 6)
print(x, SIXTEENCUBED)