# (Python Example for Citizen Data Scientist & Business Analyst)

## Write a Python program to check the sum of three elements (each from an array) from three arrays is equal to a target value. Print all those three-element combinations.

Sample data:
X = [10, 20, 20, 20]
Y = [10, 20, 30, 40]
Z = [10, 30, 40, 20]
target = 70

Sample Solution:

Python Code:

``````import itertools
from functools import partial
X = [10, 20, 20, 20]
Y = [10, 20, 30, 40]
Z = [10, 30, 40, 20]
T = 70

def check_sum_array(N, *nums):
if sum(x for x in nums) == N:
return (True, nums)
else:
return (False, nums)
pro = itertools.product(X,Y,Z)
func = partial(check_sum_array, T)
sums = list(itertools.starmap(func, pro))

result = set()
for s in sums:
if s[0] == True and s[1] not in result:
print(result)
``````

Sample Output:

```{(10, 20, 40)}
{(10, 20, 40), (10, 30, 30)}
{(10, 20, 40), (10, 30, 30), (10, 40, 20)}
{(10, 20, 40), (10, 30, 30), (20, 10, 40), (10, 40, 20)}
{(10, 20, 40), (20, 20, 30), (10, 30, 30), (20, 10, 40), (10, 40, 20)}
{(10, 20, 40), (10, 40, 20), (20, 10, 40), (10, 30, 30), (20, 20, 30), (20, 30, 20)}
{(10, 20, 40), (10, 40, 20), (20, 10, 40), (20, 40, 10), (10, 30, 30), (20, 20, 30), (20, 30, 20)}```

## Applied Machine Learning & Data Science with Python, R and SQL.

A list of Python, R and MATLAB Codes for Applied Machine Learning and Data Science https://setscholars.net/

Learn by Coding Categories:

Classification: https://setscholars.net/category/classification/

Data Analytics: https://setscholars.net/category/data-analytics/

Data Science: https://setscholars.net/category/data-science/

Data Visualisation: https://setscholars.net/category/data-visualisation/

Machine Learning Recipe: https://setscholars.net/category/machine-learning-recipe/

Supervised Learning: https://setscholars.net/category/supervised-learning/

Tabular Data Analytics: https://setscholars.net/category/tabular-data-analytics/

End-to-End Data Science Recipes: https://setscholars.net/category/a-star-data-science-recipe/

Applied Statistics: https://setscholars.net/category/applied-statistics/

Bagging Ensemble: https://setscholars.net/category/bagging-ensemble/

Boosting Ensemble: https://setscholars.net/category/boosting-ensemble/

Clustering: https://setscholars.net/category/clustering/

Data Analytics: https://setscholars.net/category/data-analytics/

Data Science: https://setscholars.net/category/data-science/

Data Visualisation: https://setscholars.net/category/data-visualisation/

Decision Tree: https://setscholars.net/category/decision-tree/

Machine Learning Recipe: https://setscholars.net/category/machine-learning-recipe/

Multi-Class Classification: https://setscholars.net/category/multi-class-classification/

Neural Networks: https://setscholars.net/category/neural-networks/

Python Machine Learning: https://setscholars.net/category/python-machine-learning/

Python Machine Learning Crash Course: https://setscholars.net/category/python-machine-learning-crash-course/

R Classification: https://setscholars.net/category/r-classification/

R for Beginners: https://setscholars.net/category/r-for-beginners/

R for Data Science: https://setscholars.net/category/r-for-data-science/

R for Data Visualisation: https://setscholars.net/category/r-for-data-visualisation/

R for Excel Users: https://setscholars.net/category/r-for-excel-users/

R Machine Learning: https://setscholars.net/category/r-machine-learning/

R Machine Learning Crash Course: https://setscholars.net/category/r-machine-learning-crash-course/

R Regression: https://setscholars.net/category/r-regression/

Regression: https://setscholars.net/category/regression/

Excel examples for beginners: https://setscholars.net/category/excel-examples-for-beginners/

C Programming tutorials & examples: https://setscholars.net/category/c-programming-tutorials/

Javascript tutorials & examples: https://setscholars.net/category/javascript-tutorials-and-examples/

Python tutorials & examples: https://setscholars.net/category/python-tutorials/

R tutorials & examples: https://setscholars.net/category/r-for-beginners/

```