```
def spaced_out(list_of_num):
if len(list_of_num) > 3:
list_of_num = list_of_num[:3]
print("keeping only first three elements")
```**(1)**
if abs(list_of_num[0]-list_of_num[1]) == abs(list_of_num[1]-list_of_num[2]): **(2)**
return "Spaced Out"
else:
return "NOT Spaced Out"

# Spaced Out?

Carvia Tech | September 10, 2019 | 1 min read | 2 views | Python Coding Problems

Given 3 different integer numbers, determine if the difference between the smallest number and the middle number is the same as the difference between the middle number and the largest number.

The numbers can be entered in any order. If the differences are exactly the same the program should indicate the numbers are "Spaced Out" otherwise the numbers are "NOT Spaced Out".

1 |
In case, input is more than three numbers then we will be considering only first three numbers as given in problem statement. |

2 |
We are checking if the array is spaced out or not by using `abs` function in python |

`print(spaced_out([1,3,5,7]))`

keeping only first three elements Spaced Out

###### Top articles in this category:

- Python coding challenges for interviews
- Python Flask Interview Questions
- Google Data Scientist interview questions with answers
- Top 100 interview questions on Data Science & Machine Learning
- Introduction to SVM, hyperplane, TF-IDF and BoW
- Why use feature selection in machine learning
- Introduction to regression, correlation, multi collinearity and 99th percentile

###### Find more on this topic:

##### Machine Learning

Data science, machine learning, python, R, big data, spark, the Jupyter notebook, and much more

Last updated 1 week ago

###### Recommended books for interview preparation:

##### Similar Posts

- Python coding challenges for interviews
- Python Flask Interview Questions
- Machine Learning based Multiple choice questions
- Sequence of Differences in Python
- Spaced Out?
- Find extra long factorials in python
- Find if credit card number is valid or not
- Imbalanced classes in classification problem in deep learning with keras
- Derivative of 1/x & Tossing a coin problem
- Introduction to SVM, hyperplane, TF-IDF and BoW

Enter your email address to subscribe to this blog and receive notifications of new posts by email.