input: Write a python function to generate a password of given length containing at least one lowercase letter, one uppercase letter, one digit, and one special character.
  assert len(generate_password(10)) == 10
  assert any(c.islower() for c in generate_password(10))
  assert any(c.isupper() for c in generate_password(10))
  assert any(c.isdigit() for c in generate_password(10))
  assert any(c in "!@#$%^&*()" for c in generate_password(10))
output: import random
  import string
  
  def generate_password(length):
      if length < 4:
          raise ValueError("Length must be at least 4 to include all character types.")
      
      password = [
          random.choice(string.ascii_lowercase),
          random.choice(string.ascii_uppercase),
          random.choice(string.digits),
          random.choice("!@#$%^&*()")
      ]
      
      if length > 4:
          remaining_chars = length - 4
          all_chars = string.ascii_letters + string.digits + "!@#$%^&*()"
          password += random.choices(all_chars, k=remaining_chars)
      
      random.shuffle(password)
      return ''.join(password)