input: Write a function to generate a random password of length 8 characters, containing at least one uppercase letter, one lowercase letter, one digit, and one special character.
  
  import string
  import random
  
  def generate_password():
     up_alphabet = string.ascii_uppercase
     low_alphabet = string.ascii_lowercase
     digits = string.digits
     symbols = string.punctuation
     length = 8
     pass_characters = up_alphabet + low_alphabet + digits + symbols
     password =  ''.join(random.sample(pass_characters, length))
     return password
  
  assert len(generate_password()) == 8
  assert any(char.isupper() for char in generate_password())
  assert any(char.islower() for char in generate_password())
  assert any(char.isdigit() for char in generate_password())
  assert any(char in string.punctuation for char in generate_password())
output: def generate_password():
     up_alphabet = string.ascii_uppercase
     low_alphabet = string.ascii_lowercase
     digits = string.digits
     symbols = string.punctuation
     password = [
         random.choice(up_alphabet),
         random.choice(low_alphabet),
         random.choice(digits),
         random.choice(symbols)
     ]
     password += random.choices(up_alphabet + low_alphabet + digits + symbols, k=4)
     random.shuffle(password)
     return ''.join(password)