Computer Science, asked by Nutanc8930, 1 year ago

Write a program to find the range of a set of numbers. range is the difference between the smallest and biggest number in the list.

Answers

Answered by Equestriadash
4

The following codes are written in Python.

Source code:

n = int(input("Enter the number of integers you'd like to enter: "))

l = list()

for i in range(n):

 x = int(input("Enter the integer: "))

 l.append(x)

print(l, "is your given list.")

l.sort()

print(l, "is the sorted list.")

s = l[-1] - l[0]

print(s, "is the range of the list.")

sort() is a function that sorts the elements in the list in the ascending/alphabetical order.

If you want to arrange them in the descending order, or backwards in regards with letters, the syntax would be:

l.sort(reverse = True)

Attachments:
Similar questions