"""

John Rachlin
DS 2000: Intro to Programming with Data

Filename: first_functions.py
    
Description: An introduction to functions

    
"""



# A function is: a named block of code which can take inputs and 
# return outputs

#%%

def hello():
    """ A simple hello-world function """
    print("Hello World!")
    print("What a nice day!")
    
    
hello()
hello()
hello()   
    
#%%
def hello(name):
    """ Say hello to <name> """
    print("Hello", name.upper())

    

#hello("John")
hello(7)

#%%

def convert(x):
    print(int(x))
    
convert("abc")

#%%

def square(x):
    """ Compute the square of a value """
    return x ** 2



y = square(10)
print(y)

#%% Travelling Salesman Problem

"""
Start in Boston

Visit 10 cities

Return to Boston

What is the optimal path?

10! = 10 * 9 * 8 ..... * 3 * 2 * 1   "ten factorial"


"""
def fact(n):
    f = 1
    for i in range (1, n+1):
        f = f * i
    return f

fact(10)


for i in range(1, 30):
    print(i, fact(i))

    
    


    
