Write a python script to generate a dictionary containing numbers from 1 to n as keys and their square as values.
def generate_dict(n):
    d = {}
    for i in range(1, n+1):
        d[i] = i*i
    return d