Computer Science, asked by austin7522, 7 months ago

Accept a list of integers and print the smallest and largest integers without using max() or min(). in python

Answers

Answered by imtiyazallam
5

Answer:

#Let us accept 3 numbers.

def largest(a, b, c):

  if(a > b and a > c):

     return a

  elif (b > c):

     return b

  else:

     return c

def smallest(a, b, c):

  if(a < b and a < c):

     return a

  elif (b < c):

     return b

  else:

     return c

a = int(input("Enter 1st number: "))

b = int(input("Enter 2nd number: "))

c = int(input("Enter 3rd number: "))

if(a == b or b == c or c == a):

  print("You must enter a unique number.")

else:

  print("The largest number is", largest(a, b,c))

  print("The smallest number is", smallest(a, b,c))

Similar questions