5.2 Imported functions - JulTob/Python GitHub Wiki
Using function from in-built modules e.g. Import function sqrt from the math module. To get a list of supported modules, use help("modules").
from math import sqrt
# Get value from the user
num = eval(input("Enter number: "))
# Compute the square root
root = sqrt(num);
# Report result
print("Square root of", num, "=", root)
User-defined functions
# Count to ten and print each number on its own line
def count_to_num(n):
for i in range(1, n+1):
print(i)
print("Going to count to ten . . .")
count_to_num(10)