write a program to find the lowest and second largest number from the 10 numbers input (python)
Answers
Answered by
14
The following cσdes have been written using Python.
l = list()
for i in range(10):
x = int(input("Enter an integer: "))
l.append(x)
print()
print(l, "is your given list of integers.")
print()
l.sort()
print(l, "is your sorted list of integers.")
print()
print(l[0], "and", l[-2], "are the lowest and second lowest integers among the 10 integers input. ")
- The append() fυnction is used to add elements to a list.
- The sort() fυnction is used to sort the elements in a list, in ascending/descending order. It cannot be used if the list has more than 1 datatype.
Answered by
6
Program
numbers = sorted([int(number) for number in input("Enter the numbers - ").split( )])
print("Second largest number -", numbers[-2])
print("Smallest number -", numbers[0])
Algorithm
- Accepting and sorting the numbers.
- Displaying the required numbers as specified by the question.
Attachments:
Similar questions