code: def categories_percent(s, categories):
      '''Returns category characters percent.
  
      >>> categories_percent("qqq ggg hhh", ["Po"])
      0.0
      >>> categories_percent("q,w.", ["Po"])
      50.0
      >>> categories_percent("qqq ggg hhh", ["Nd"])
      0.0
      >>> categories_percent("q5", ["Nd"])
      50.0
      >>> categories_percent("s.s,5s", ["Po", "Nd"])
      50.0
      '''
      count = 0
      s = to_unicode(s, precise=True)
      for c in s:
          if unicodedata.category(c) in categories:
              count += 1
      return 100 * float(count) / len(s) if len(s) else f categories_percent(s, categories):
      '''Returns category characters percent.
  
      >>> categories_percent("qqq ggg hhh", ["Po"])
      0.0
      >>> categories_percent("q,w.", ["Po"])
      50.0
      >>> categories_percent("qqq ggg hhh", ["Nd"])
      0.0
      >>> categories_percent("q5", ["Nd"])
      50.0
      >>> categories_percent("s.s,5s", ["Po", "Nd"])
      50.0
      '''
      count = 0
      s = to_unicode(s, precise=True)
      for c in s:
          if unicodedata.category(c) in categories:
              count += 1
      return 100 * float(count) / len(s) if len(s) else 0
docs: Returns category characters percent.
  
      >>> categories_percent("qqq ggg hhh", ["Po"])
      0.0
      >>> categories_percent("q,w.", ["Po"])
      50.0
      >>> categories_percent("qqq ggg hhh", ["Nd"])
      0.0
      >>> categories_percent("q5", ["Nd"])
      50.0
      >>> categories_percent("s.s,5s", ["Po", "Nd"])
      50.0