input: Write a python function to train a logistic regression model and calculate its accuracy using sklearn.
  assert train_and_evaluate([[0.3, 0.2, 0.6], [0.3, 0.1, 0.4], [0.2, 0.3, 0.4], [0.7, 0.4, 0.2], [0.5, 0.2, 0.1]], [1, 0, 0, 1, 0])==1.0
  assert train_and_evaluate([[0.1, 0.2, 0.3], [0.4, 0.1, 0.5], [0.2, 0.5, 0.1], [0.7, 0.4, 0.2], [0.6, 0.2, 0.4]], [0, 0, 1, 1, 1])>0.5
output: def train_and_evaluate(X, y):
      from sklearn.linear_model import LogisticRegression
      from sklearn.model_selection import train_test_split
      from sklearn.metrics import accuracy_score
      
      # Split the data into training and test sets
      X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
      
      # Create and train the logistic regression model
      model = LogisticRegression()
      model.fit(X_train, y_train)
      
      # Make predictions on the test set
      y_pred = model.predict(X_test)
      
      # Calculate the accuracy
      accuracy = accuracy_score(y_test, y_pred)
      
      return accuracy