User Rating: 0 / 5

Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive

If13. Three numbers are given. Find the central of them (that is, the number between the smallest and largest).

Solution in Python 3:

import random

A = random.randrange(-30,30)
B = random.randrange(-30,30)
C = random.randrange(-30,30)

print("Number A:", A)
print("Number B:", B)
print("Number C:", C)

if (A <= B and B <= C) or (C <= B and B <= A):
m = B
elif (B <= A and A <= C) or (C <= A and A <= B):
m = A
elif (A <= C and C <= B) or (B <= C and C <= A):
m = C

print("Central:", m)