# Python Exercise – Return true if the two given int values are equal or their sum or difference is 5

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

Write a Python program which will return true if the two given integer values are equal or their sum or difference is 5.

Sample Solution

Python Code:

``````def test_number5(x, y):
if x == y or abs(x-y) == 5 or (x+y) == 5:
return True
else:
return False

print(test_number5(7, 2))
print(test_number5(3, 2))
print(test_number5(2, 2))
``````

Sample Output:

```True
True
True
```

Flowchart:

## 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/

```