- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Python – Consecutive Division in List
When it is required to find the consecutive division in a list, a method is defined that iterates over the elements of the list and uses the ‘/’ operator to determine the result.
Below is a demonstration of the same −
Example
def consec_division(my_list): my_result = my_list[0] for idx in range(1, len(my_list)): my_result /= my_list[idx] return my_result my_list = [2200, 500, 100, 50, 20, 5] print("The list is :") print(my_list) my_result = consec_division(my_list) print("The result is :") print(my_result)
Output
The list is : [2200, 500, 100, 50, 20, 5] The result is : 8.8e-06
Explanation
A method named ‘consec_division’ is defined that takes a list as a parameter.
It assigns the zeroth index to a variable.
The list is iterated over, and the ‘/’ operator is used to divide every element by the first element.
This is returned as result.
Outside the method, a list is defined and is displayed on the console.
The method is called by passing the list.
This is assigned to a variable.
It is displayed as output on the console.
- Related Articles
- Consecutive elements pairing in list in Python
- Check if list contains consecutive numbers in Python
- Consecutive Nth column Difference in Tuple List using Python
- Average of each n-length consecutive segment in a Python list
- Division Operators in Python?
- Tuple Division in Python
- Python – Extract range of Consecutive similar elements ranges from string list
- Check if absolute difference of consecutive nodes is 1 in Linked List in Python
- Longest Consecutive Sequence in Python
- Remove Consecutive Duplicates in Python
- Program to check whether we can split list into consecutive increasing sublists or not in Python
- How to perform the Integer division operation of a pandas Series by a Python list?
- Python – Extend consecutive tuples
- Consecutive element maximum product in Python
- Swap Consecutive Even Elements in Python

Advertisements