Answers for "find the range in python"

10

python range

# range(start, stop, step)
  # start = (can be ommitted) index to begin at (INCLUSIVE)
  # stop = generate numbers up to, but not including this number (EXCLUSIVE)
  # step = (can be omitted) difference between each number in the sequence

# idx:  0	1	2	3 	4
# arr:  19	5	3	22	13
  
arr = [19,5,3,22,13]

# range(stop)
for i in range(len(arr)):
    print(arr[i]) # prints: 19, 5, 3, 22, 13

# range(start, stop)
for i in range(2, len(arr)):
    print(arr[i]) # prints: 3, 22, 13
    
# range(start, stop, step)
for i in range(0, len(arr), 2):
    print(arr[i]) # prints: 19, 3, 13
    
# reverse:
for i in range(len(arr)-1, -1, -1):
    print(arr[i])
Posted by: Guest on June-09-2020
-1

find the range in python

def find_range(n):
    lowest = min(n)
    highest = max(n)
    # Find the range
    r = highest - lowest
    
    return lowest, highest, r
  
# src : Doing Math With Python
Posted by: Guest on December-29-2020

Code answers related to "find the range in python"

Python Answers by Framework

Browse Popular Code Answers by Language