I really suggest you to take a look over the documentation. A simple loop would solve your problem:
a = [1, 2, 3, 4, 5]
results = []
for i in range(len(a)-1):
results.append((a[i]+a[i+1])/2)
print(results)
Output: [1.5, 2.5, 3.5, 4.5]
More Related Contents:
- Python read from txt and save into mysql
- Calculate How Many Card Transaction [closed]
- python without conda or anaconda [closed]
- ‘order’ of unordered Python sets
- How to read a file with a semi colon separator in pandas
- subprocess.call using string vs using list
- Encoding an image file with base64
- How to retrieve inserted id after inserting row in SQLite using Python?
- How to find the groups of consecutive elements in a NumPy array
- Python Requests – How to use system ca-certificates (debian/ubuntu)?
- Python how to write to a binary file?
- Converting string “Jun 1 2005 1:33PM” into datetime
- asyncio CancelledError and KeyboardInterrupt
- NLTK-based text processing with pandas
- Python unittest passing arguments
- ‘ModuleNotFoundError’ when trying to import module from imported package
- Assign pandas dataframe column dtypes
- Conda – offline install / update
- Why is a `for` over a Python list faster than over a Numpy array?
- parsing nested parentheses in python, grab content by level
- Python float to int conversion
- Is there a WebSocket client implemented for Python? [closed]
- Relative Strength Index in python pandas
- Converting python string into bytes directly without eval()
- Numpy shuffle multidimensional array by row only, keep column order unchanged
- How do I re-map python dict keys
- When is plt.show() required to show a plot and when is it not?
- Python 2.7: Print thread safe
- how to specify the datetime format in read_csv
- Get total values_count from a dataframe with Python Pandas