```python
def merge_dict(d1, d2):
    """
    Merges two dictionaries.

    If a key exists in both dictionaries, the value from the second
    dictionary (d2) will be used.

    Args:
        d1: The first dictionary.
        d2: The second dictionary.

    Returns:
        A new dictionary containing the merged key-value pairs.
    """
    merged_dict = d1.copy()
    merged_dict.update(d2)
    return merged_dict

```