0 out of 68 challenges solved

Generate a dictionary of squared numbers

Question:
Write a function called generate_dictionary that takes a number as input and generates a dictionary containing (i, i*i) pairs for each integral number between 1 and the given number (both inclusive). The function should return the generated dictionary.

Example:
Input: 8
Output: {1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64}

def generate_dictionary(n):
    """
    Generates a dictionary containing (i, i*i) pairs for each integral number between 1 and n (both inclusive).

    Args:
    n (int): The input number.

    Returns:
    dict: The generated dictionary.
    """
    # TODO: Implement the generate_dictionary function
    pass