Can we make the machine learn Gates (OR AND XOR etc.) Below is the NAND Gate truth table, there are 2 independent features A,B and one dependent feature Y in the dataset.
Can we make the machine learn this if YES how ? if No why ? 
Please go through the attempt below where the classifier model stumble on [0,0] point and can't predict it correctly giving .75 accuracy.

import pandas as pd 
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import confusion_matrix,classification_report,accuracy_score

x_train = [[0,0],[0,1],[1,0],[1,1]]
y_train = [1,1,1,0]

x_test = [[1,1],[1,0],[0,1],[0,0]]

clf_lr = LogisticRegression()
clf_lr.fit(x_train,y_train)
prediction = clf_lr.predict(x_test)

print(prediction) 
[1 1 1 1]

print(accuracy_score(y_train,prediction))
0.75

print(confusion_matrix(y_train,prediction)) 
[[0 1]
 [0 3]]

print(classification_report(y_train,prediction))


              precision    recall  f1-score   support

          0       0.00      0.00      0.00         1
          1       0.75      1.00      0.86         3

avg / total       0.56      0.75      0.64         4

 A: The answer to the title question is "yes," many machine learning models are capable of learning various logical gates.  @KarelMacek is correct that the XOR gate is famously not linearly separable, so logistic regression will not be able to learn that one.
But your example is the NAND gate, which is linearly separable, so a logistic regression should be able to learn it.  The problem is that sklearn applies L2 regularization by default, which is preventing the model from learning the pattern "strongly" enough.  You can see from clf_lr.predict_proba(x_test)[:, 1] that the model has learned that $(1,1)$ is less likely to be a 1, but the regularization has prevented the probability from dropping below $0.5$.  You can reduce the regularization strength, or better set penalty='none', to recover correct predictions.
A: Ben Reiniger is right, but you also have an additional problem (a bug) that your x_test has a different ordering than y_train. You actually don't need x_test at all.
Here is the complete code:
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import confusion_matrix, classification_report, accuracy_score

x_train = [[0,0],[0,1],[1,0],[1,1]]
y_train = [1,1,1,0]

clf_lr = LogisticRegression(penalty='none')
clf_lr.fit(x_train, y_train)
prediction = clf_lr.predict(x_train)
print(prediction)
# [1 1 1 0]
print(accuracy_score(y_train, prediction))
# 1.0
print(confusion_matrix(y_train, prediction))
# [[1 0]
#  [0 3]]
print(classification_report(y_train, prediction))
#               precision    recall  f1-score   support
#
#            0       1.00      1.00      1.00         1
#            1       1.00      1.00      1.00         3
#
#     accuracy                           1.00         4
#    macro avg       1.00      1.00      1.00         4
# weighted avg       1.00      1.00      1.00         4

A: It is well known that XOR cannot be solved by a linear classifier (e.g. logistic regression):
http://www.ece.utep.edu/research/webfuzzy/docs/kk-thesis/kk-thesis-html/node19.html
Try to use SVM with either RBF or polynomial kernels:
http://scikit-learn.org/stable/modules/svm.html
