code: def cast_to_number_or_bool(inputstr):
      
      if inputstr.strip().lower() == "true":
          return True
      elif inputstr.strip().lower() == "false":
          return False
      try:
          return int(inputstr)
      except ValueError:
          try:
              return float(inputstr)
          except ValueError:
              return inputstr
docs: Cast a string to int, float or bool. Return original string if it can't be
      converted.
  
      Scientific expression is converted into float.